Reputation: 818
In Snowflake, There is a concept named Snowpipe which will load the data automatically to configured tables from the different data sources.
We are trying to do the normalization while loading into the snowflake via Snowpipe.
Table A:
Id & EmployerName
Table B:
Id, Employeename & EmployerID
Value in the File
Name, EmployerName
Raj, Google
Kumar, Microsoft
We are unable to populate table A & table B in a same pipe as the pipe has only one copy statement.
Is there any concept like dependent PIPE & other ways to load the lookup table first & load the main table from the sample file?
Note:
Upvotes: 3
Views: 1208
Reputation: 1321
I have an idea to do for multiple table copy:
This will populate your data in you target table in given interval. Using this option the file won't be copied immediately from your source location. Have to check the option on TASK hoe to get notified on each run.
Upvotes: 1
Reputation: 11
Just a few ideas:
Set up a Snowpipe to load into a single permanent staging area (PSA) table.
Use hash codes as the surrogate key for the two separated tables (if you have to use surrogate keys, at all). This way you don't have to do lookups for the surrogate key values. Your tables will look like: TableA - EmployerHash, EmployerName; TableB - EmployeeHash, EmployeeName, EmployerHash;
Then create a Task with a stored procedure, that will issue a multi-table insert so that you will load into the two tables at the same time by using the same source query. (https://docs.snowflake.net/manuals/sql-reference/sql/insert-multi-table.html#insert-multi-table)
HTH, Gabor
Upvotes: 1
Reputation: 6229
Snowpipe should be used to load data into tables as soon as the source data is available in the cloud provider's blob storage location. You cannot set up a dependancy between Snowpipes, this would add a delay into the pipeline anyway.
Your best bet is to set up two Snowpipes to load both tables as soon as data arrives in blob storage and then use Snowflake tasks to handle the dependancies and business logic.
Upvotes: 2