-
Notifications
You must be signed in to change notification settings - Fork 48
/
prepare_data.sh
executable file
·71 lines (57 loc) · 2.13 KB
/
prepare_data.sh
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
71
snow sql -q "CREATE OR REPLACE WAREHOUSE NATIVE_APP_QUICKSTART_WH WAREHOUSE_SIZE=SMALL INITIALLY_SUSPENDED=TRUE;
-- this database is used to store our data
CREATE OR REPLACE DATABASE NATIVE_APP_QUICKSTART_DB;
USE DATABASE NATIVE_APP_QUICKSTART_DB;
CREATE OR REPLACE SCHEMA NATIVE_APP_QUICKSTART_SCHEMA;
USE SCHEMA NATIVE_APP_QUICKSTART_SCHEMA;
-- create provider shipping data table
CREATE OR REPLACE TABLE MFG_SHIPPING (
order_id NUMBER(38,0),
ship_order_id NUMBER(38,0),
status VARCHAR(60),
lat FLOAT,
lon FLOAT,
duration NUMBER(38,0)
);"
# create consumer orders data table
snow sql -q "USE WAREHOUSE NATIVE_APP_QUICKSTART_WH;
-- this database is used to store our data
USE DATABASE NATIVE_APP_QUICKSTART_DB;
USE SCHEMA NATIVE_APP_QUICKSTART_SCHEMA;
CREATE OR REPLACE TABLE MFG_ORDERS (
order_id NUMBER(38,0),
material_name VARCHAR(60),
supplier_name VARCHAR(60),
quantity NUMBER(38,0),
cost FLOAT,
process_supply_day NUMBER(38,0)
);
-- create consumer recovery data table
CREATE OR REPLACE TABLE MFG_SITE_RECOVERY (
event_id NUMBER(38,0),
recovery_weeks NUMBER(38,0),
lat FLOAT,
lon FLOAT
);
"
# loading shipping data into table stage
snow object stage copy ./app/data/shipping_data.csv @%MFG_SHIPPING --database NATIVE_APP_QUICKSTART_DB --schema NATIVE_APP_QUICKSTART_SCHEMA
# loading orders data into table stage
snow object stage copy ./app/data/order_data.csv @%MFG_ORDERS --database NATIVE_APP_QUICKSTART_DB --schema NATIVE_APP_QUICKSTART_SCHEMA
# loading site recovery data into table stage
snow object stage copy ./app/data/site_recovery_data.csv @%MFG_SITE_RECOVERY --database NATIVE_APP_QUICKSTART_DB --schema NATIVE_APP_QUICKSTART_SCHEMA
#load data from table stages into tables
snow sql -q"USE WAREHOUSE NATIVE_APP_QUICKSTART_WH;
-- this database is used to store our data
USE DATABASE NATIVE_APP_QUICKSTART_DB;
USE SCHEMA NATIVE_APP_QUICKSTART_SCHEMA;
COPY INTO MFG_SHIPPING
FILE_FORMAT = (TYPE = CSV
FIELD_OPTIONALLY_ENCLOSED_BY = '\"');
COPY INTO MFG_ORDERS
FILE_FORMAT = (TYPE = CSV
FIELD_OPTIONALLY_ENCLOSED_BY = '\"');
COPY INTO MFG_SITE_RECOVERY
FILE_FORMAT = (TYPE = CSV
FIELD_OPTIONALLY_ENCLOSED_BY = '\"');
"