-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupload_data.sql.template
70 lines (66 loc) · 6.04 KB
/
upload_data.sql.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
create or replace stage {{.Stage}};
create or replace file format {{.FileFormat}} type = 'csv' field_delimiter = ',' skip_header = 1 FIELD_OPTIONALLY_ENCLOSED_BY = '"' ;
USE WAREHOUSE {{.TgtWarehouse}};
put 'file://{{.Out}}/*.gz' @{{.Stage}};
put 'file://{{.Out}}/*.csv' @{{.Stage}};
list @{{.Stage}};
truncate table if exists metering_history;
copy into metering_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1 COMPRESSION = AUTO ) pattern = 'metering_history.*.csv.gz' on_error='continue';
select count(*) from metering_history;
truncate table if exists metering_daily_history;
copy into metering_daily_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1 COMPRESSION = AUTO ) pattern = 'metering_daily_history.*.csv.gz' on_error='continue';
select count(*) from metering_daily_history;
truncate table if exists tables;
copy into tables from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1 COMPRESSION = AUTO ) pattern = 'tables.*.csv.gz' on_error='continue';
select count(*) from tables;
truncate table if exists warehouse_load_history;
copy into warehouse_load_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'warehouse_load_history.*.gz' on_error='continue';
select count(*) from warehouse_load_history;
truncate table if exists warehouse_events_history;
copy into warehouse_events_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'warehouse_events_history.*.gz' on_error='continue';
select count(*) from warehouse_events_history;
truncate table if exists warehouse_metering_history;
copy into warehouse_metering_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'warehouse_metering_history.*.gz' on_error='continue';
select count(*) from warehouse_metering_history;
truncate table if exists query_history;
copy into query_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'query_history.*.gz' on_error='continue';
select count(*) from query_history;
truncate table if exists access_history;
copy into access_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'access_history.*.gz' on_error='continue';
select count(*) from access_history;
truncate table if exists warehouses;
copy into warehouses from @{{.Stage}}/ file_format = (type = 'csv' FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1 NULL_IF = ('NULL','null','')) PATTERN = 'warehouses.*.gz' on_error='continue';
select count(*) from warehouses;
truncate table if exists warehouse_parameters;
copy into warehouse_parameters from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'warehouse_parameters.*.gz' on_error='continue';
select count(*) from warehouse_parameters;
truncate table if exists database_replication_usage_history;
copy into database_replication_usage_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'database_replication_usage_history.*.gz' on_error='continue';
select count(*) from database_replication_usage_history;
truncate table if exists replication_group_usage_history;
copy into replication_group_usage_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'replication_group_usage_history.*.gz' on_error='continue';
select count(*) from replication_group_usage_history;
truncate table if exists database_storage_usage_history;
copy into database_storage_usage_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'database_storage_usage_history.*.gz' on_error='continue';
select count(*) from database_storage_usage_history;
truncate table if exists stage_storage_usage_history;
copy into stage_storage_usage_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'stage_storage_usage_history.*.gz' on_error='continue';
select count(*) from stage_storage_usage_history;
truncate table if exists search_optimization_history;
copy into search_optimization_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'search_optimization_history.*.gz' on_error='continue';
select count(*) from search_optimization_history;
truncate table if exists data_transfer_history;
copy into data_transfer_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'data_transfer_history.*.gz' on_error='continue';
select count(*) from data_transfer_history;
truncate table if exists automatic_clustering_history;
copy into automatic_clustering_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'automatic_clustering_history.*.gz' on_error='continue';
select count(*) from automatic_clustering_history;
truncate table if exists snowpipe_streaming_file_migration_history;
copy into snowpipe_streaming_file_migration_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'snowpipe_streaming_file_migration_history.*.gz' on_error='continue';
select count(*) from snowpipe_streaming_file_migration_history;
truncate table if exists auto_refresh_registration_history;
copy into auto_refresh_registration_history from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'auto_refresh_registration_history.*.gz' on_error='continue';
select count(*) from auto_refresh_registration_history;
truncate table if exists tag_references;
copy into tag_references from @{{.Stage}}/ file_format = (type = csv FIELD_OPTIONALLY_ENCLOSED_BY = '"' SKIP_HEADER = 1) PATTERN = 'tag_references.*.gz' on_error='continue';
select count(*) from tag_references;