I have a table which get loaded from S3 every time when there is a new file in bucket. And I am using Snowpipe to do so.
However the ask is to refresh the table in every load. To accomplish that, My thought process is below.
- Create a pipe on table t1 to copy from S3.
- Create a Stream on table t1.
- Create a task to run every 5 min and condition when stream has data. The Task statement will be to delete the record from table where load_date of stream is not equal to the load_date of Table. (Using stream to implement DML operation on Stream so that Stream get empty)
So Basically using the Self stream to delete the data from the table. However my issue is what will happen when there is multiple load on the same day. And this approach does not look very professional. Is there a better way.