-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstage_load.sql
66 lines (54 loc) · 1.7 KB
/
stage_load.sql
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
-- Creates staging area for loading data into Snowflake
begin;
-- creates compressed csv file format
create or replace file format csv_gz_format
type = 'csv'
compression = 'gzip'
field_delimiter = ','
skip_header = 1;
-- creates alternate compressed csv file format
create or replace file format csv_gz_format_0
type = 'csv'
compression = 'gzip'
field_delimiter = ','
skip_header = 1;
commit;
begin;
-- create a staging area
create or replace stage stg_transactions
file_format = csv_gz_format
COMMENT = 'Staging for credit card data.';
commit;
-- list specified staging area
list @stg_transactions;
/*
-- SnowSQL client commands:
-- 1. staging - PUT
-- 2. bulk loading - COPY INTO
PUT file://data/credit_card_transactions-ibm_v2.csv @stg_transactions/;
copy into transactions_v1
from @stg_transactions/credit_card_transactions-ibm_v2.csv.gz
file_format = (format_name = 'csv_gz_format')
on_error = 'continue'
force = true;
copy into transactions_v2
from @stg_transactions/credit_card_transactions-ibm_v2.csv.gz
file_format = (format_name = 'csv_gz_format')
on_error = 'continue'
force = true;
copy into transactions_v3
from @stg_transactions/credit_card_transactions-ibm_v2.csv.gz
file_format = (format_name = 'csv_gz_format')
on_error = 'continue'
force = true;
copy into transactions_v4
from @stg_transactions/credit_card_transactions-ibm_v2.csv.gz
file_format = (format_name = 'csv_gz_format')
on_error = 'continue'
force = true;
copy into transactions_v5
from @stg_transactions/credit_card_transactions-ibm_v2.csv.gz
file_format = (format_name = 'csv_gz_format')
on_error = 'continue'
force = true;
*/