-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSnowSQL-Command.txt
49 lines (36 loc) · 1.65 KB
/
SnowSQL-Command.txt
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
--Login to Snow SQL
snowsql
-- Create PIPE FORMAT
create or replace file format PIPE_FORMAT_CLI
type = 'CSV'
field_delimiter = '|'
skip_header = 1;
-- Create stage for snowflake
create or replace stage PIPE_CLI_STAGE
file_format = PIPE_FORMAT_CLI;
--Put customer_detail csv in stage. Snowflake will load the table from this stage
put file:///Users/isaacabrahamodeh/Desktop/Real-Time-Data-Warehouse/teslaData/customer_detail.csv @PIPE_CLI_STAGE auto_compress=true;
--Put customer_detail csv in stage. Snowflake will load the table from this stage
PUT file:///Users/isaacabrahamodeh/Desktop/snowflake-data-warehouse/teslaData/customer_detail.csv @PIPE_CLI_STAGE auto_compress=true;
put file://C:\Users\varjain6\Desktop\projectpro\teslaData\customer_detail.csv @PIPE_CLI_STAGE auto_compress=true;
--List stage to see how nmany files are loaded in stage
list @PIPE_CLI_STAGE;
--Resume warehouse. In our case warehouse is set to auto-resume so no need to run this command.
alter warehouse compute_wh resume;
--Finally copy command to load data into table from stage
USE WAREHOUSE DEMO_WH
copy into customer_detail
from @PIPE_CLI_STAGE
file_format = (format_name = PIPE_FORMAT_CLI)
on_error = 'skip_file';
--Finally copy command to load data into table from stage
copy into customer_detail
from @PIPE_CLI_STAGE
file_format = (format_name = PIPE_FORMAT_CLI)
on_error = 'skip_file';
--We can also give copy command with pattern if your stage contain multiple files.
copy into mycsvtable
from @my_csv_stage
file_format = (format_name = mycsvformat)
pattern='.*contacts[1-5].csv.gz'
on_error = 'skip_file';