-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a procedure for each parquet datatype
- Loading branch information
1 parent
2202e0f
commit 1d37ce9
Showing
3 changed files
with
87 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 57 additions & 3 deletions
60
snowflake/objects/database/recover/schema/parquet/procedure/deploy.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,61 @@ | ||
/* | ||
Deploy all PROCEDURE objects | ||
This script does nothing (yet) because all of our procuedures are stage-specific. | ||
See limitations of specifying variables in stage names in | ||
`copy_into_table_from_stage.sql`. | ||
Jinja templating variables: | ||
stage_name - The name of the stage where our data exists. | ||
file_format - The name of the file format object used by the | ||
`copy_into_table_from_stage.sql` procedure. | ||
*/ | ||
|
||
WITH AS PROCEDURE () | ||
RETURNS VARCHAR | ||
LANGUAGE SQL | ||
AS | ||
$$ | ||
DECLARE | ||
parquet_datatypes ARRAY := [ | ||
'enrolledparticipants_customfields_symptoms', | ||
'enrolledparticipants_customfields_treatments', | ||
'enrolledparticipants', | ||
'fitbitactivitylogs', | ||
'fitbitdailydata', | ||
'fitbitdevices', | ||
'fitbitecg', | ||
'fitbitecg_waveformsamples', | ||
'fitbitintradaycombined', | ||
'fitbitrestingheartrates', | ||
'fitbitsleeplogs', | ||
'fitbitsleeplogs_sleeplogdetails', | ||
'googlefitsamples', | ||
'healthkitv2activitysummaries', | ||
'healthkitv2electrocardiogram', | ||
'healthkitv2electrocardiogram_subsamples', | ||
'healthkitv2heartbeat', | ||
'healthkitv2heartbeat_subsamples', | ||
'healthkitv2samples', | ||
'healthkitv2statistics', | ||
'healthkitv2workouts_events', | ||
'healthkitv2workouts', | ||
'symptomlog', | ||
'symptomlog_value_symptoms', | ||
'symptomlog_value_treatments' | ||
]; | ||
datatype VARCHAR; | ||
dataset_name VARCHAR; | ||
BEGIN | ||
FOR i in 0 to array_size(:parquet_datatypes)-1 DO | ||
datatype := GET(:parquet_datatypes, :i); | ||
dataset_name := CONCAT('dataset_', :datatype); | ||
-- Create a stored procedure which uses this data type's stage location | ||
EXECUTE IMMEDIATE | ||
FROM './copy_into_table_from_stage.sql' | ||
USING ( | ||
datatype => :datatype, | ||
stage_name => '{{ stage_name }}', | ||
stage_path => :dataset_name, | ||
file_format => '{{ file_format }}' | ||
); | ||
END FOR; | ||
END; | ||
$$ | ||
CALL create_procedure_for_each_parquet_table(); |