@@ -190,6 +190,7 @@ def biomark_pit_salmon(
190190 get_readers_voltage_data (client , locations , begin_date , end_date ),
191191 name = "readers_voltage" ,
192192 primary_key = ["reader__site__slug" , "read_at" ],
193+ write_disposition = "merge" ,
193194 )
194195 yield readers_resource
195196
@@ -253,7 +254,7 @@ def run(
253254
254255 # Set up DLT pipeline
255256 pipeline = dlt .pipeline (
256- pipeline_name = "biomark_pit " ,
257+ pipeline_name = "biomark_pit_registering_salmon_v1_test " ,
257258 destination = "duckdb" ,
258259 dataset_name = "main" ,
259260 progress = "log" ,
@@ -288,7 +289,9 @@ def replicate(
288289 os .environ ["AWS_SECRET_ACCESS_KEY" ] = secret_key
289290 os .environ ["AWS_REGION" ] = region
290291 os .environ ["AWS_ENDPOINT" ] = endpoint_url
291- os .environ ["DUCKDB" ] = "{type: duckdb, instance: biomark_pit.duckdb}"
292+ os .environ ["DUCKDB" ] = (
293+ "{type: duckdb, instance: biomark_pit_registering_salmon_v1.duckdb}"
294+ )
292295
293296 Replication (
294297 source = "DUCKDB" ,
@@ -299,15 +302,25 @@ def replicate(
299302 "target_options" : {"format" : "parquet" },
300303 },
301304 streams = {
302- "readers_voltage" : {
303- "primary_key" : ["location_name" , " read_at" ],
305+ "readers_voltage__" + location : {
306+ "primary_key" : ["read_at" ],
304307 "update_key" : "read_at" ,
305- "object" : "tables/{stream_name}/{part_year}/{part_month}/{part_day}" ,
308+ "object" : (
309+ f"test/readers_voltage/location={ location } /"
310+ f"{{part_year}}/{{part_month}}/{{part_day}}"
311+ ),
306312 "mode" : "incremental" ,
307313 "target_options" : {"format" : "parquet" },
314+ "sql" : (
315+ "select * replace (read_at at time zone 'UTC' as read_at) "
316+ "from readers_voltage where reader__site__slug = ? "
317+ "and {incremental_where_cond}"
318+ ),
319+ "sql_parameters" : [location ],
308320 }
321+ for location in SITES .values ()
309322 },
310- env = {"SLING_STATE" : "NINAS3/data/sling" },
323+ env = {"SLING_STATE" : "NINAS3/data/sling" , "SLING_DIRECT_INSERT" : "True" },
311324 debug = True ,
312325 ).run ()
313326
0 commit comments