andreas_zaidan
10/25/2021, 1:50 PMsinger-sdk
🙂 I am developing a target
and I’m writing batches into a temporary table in my database. I would like to overwrite the final table with the newly created temporary table at the end of all batches from the sink
. I didn’t find a function called at the end of all batches in the sdk, maybe I overlooked something ?
Why : If we copy the temporary data into the target table for each batch, we obtain a target table partially filled in production
Thank you 😉visch
10/25/2021, 2:04 PMclean_up
https://gitlab.com/autoidm/autoidm-target-mssql/-/blob/main/target_mssql/streams.py#L323visch
10/25/2021, 2:04 PMvisch
10/25/2021, 2:07 PMandreas_zaidan
10/25/2021, 2:12 PMsdk
😉visch
10/25/2021, 2:17 PMvisch
10/25/2021, 2:18 PMprocess_batch
andreas_zaidan
10/25/2021, 2:20 PMvisch
10/25/2021, 2:22 PMdrain_all
is called more than just there, so this may not be the answer you're looking for.
https://sourcegraph.com/gitlab.com/meltano/sdk@main/-/blob/singer_sdk/target_base.py?L303:14#tab=references
If your schema changes it'll get called as wellvisch
10/25/2021, 2:23 PMprocess_batch
, might be a good idea to get a clean_up
function added? Not clear to meandreas_zaidan
10/25/2021, 2:23 PMandreas_zaidan
10/25/2021, 2:24 PMprocess_batch
is running for each batch , but I only want to clean at the end all all batchespat_nadolny
10/25/2021, 3:01 PMprocess_batch
or theres a chance that the state bookmarks could be incorrect (i.e. state says records were written but they never got transferred from the temp table so the next sync skips those records and the target table is out of sync).pat_nadolny
10/25/2021, 3:03 PMcurrently_syncing
state entry. I think this could make draining more efficient to.aaronsteers
10/25/2021, 3:08 PMACTIVATE_VERSION
message if the tap supports it. Are you primarily thinking of incremental or full table sync operations? For incremental operations, you might literally never finish the stream in cases like the proposed --tail mode, so it's important to be saving and cleaning up batches as you go.andreas_zaidan
10/25/2021, 3:11 PMaaronsteers
10/25/2021, 3:12 PMandreas_zaidan
10/25/2021, 3:13 PMpat_nadolny
10/25/2021, 3:15 PMACTIVATE_VERSION
if youre not familiar - https://hub.meltano.com/singer/docs#activate-versionaaronsteers
10/25/2021, 5:22 PMaaronsteers
10/25/2021, 5:26 PMaaronsteers
10/25/2021, 6:04 PMprocess_endofpipe()
aaronsteers
10/25/2021, 6:07 PMandreas_zaidan
10/26/2021, 8:46 AMprocess_endofpipe
is called before a drain_all
?aaronsteers
10/26/2021, 1:36 PMaaronsteers
10/26/2021, 8:14 PMaaronsteers
10/27/2021, 3:32 PMandreas_zaidan
10/27/2021, 3:38 PMcleanup_target
should be aware of the ending state of the operation 😉 For example :
• if failed I would like to clean up my temp tables
• If successed I would like to commit the table to productionaaronsteers
10/27/2021, 3:42 PM