I'm loading data to snowflake using an approach I found on the forums snowpipe -> load_table <-> staging table -> final table I have a task tree that check the stream on the load_table and if it finds data, swaps the load_table with the staging_table further tasks process the staging_table into the final table The staging_table is then truncated and swapped back with the load_table
This typically works fine, but the problem I am seeing is that I end up with orphan records on either the load_table or the staging_table and the load_stream is empty. Its at the point right now where even if I manually insert data into the load_table the stream is still marked as empty so no tasks run.
What is the expected behaviour when swapping tables that contain streams, is the above behaviour supported or do I need to look at an alternative? The goal is to use snowpipe to load files from S3 into a temp table and merge them into a final table, without having an ever growing staging table to manage...
Thanks!
/edit doing some some experimenting and it seems that when the tables are swapped the stream still listens to the "original" table so will ignore any data that snowpipe loads to the "new" table, even though that new table has swapped with the original...
STREAMS
. Just have a single table with a stream over it and MERGE directly from the stream. – Mike Walton