-
Notifications
You must be signed in to change notification settings - Fork 0
/
init_s3_sources.sql
91 lines (72 loc) · 2.89 KB
/
init_s3_sources.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{% macro init_s3_sources() -%}
{% set sql1 %}
CREATE TABLE IF NOT EXISTS {{ var('schema') }}.src_customer
(
C_CUSTKEY UInt32,
C_NAME String,
C_ADDRESS String,
C_CITY LowCardinality(String),
C_NATION LowCardinality(String),
C_REGION LowCardinality(String),
C_PHONE String,
C_MKTSEGMENT LowCardinality(String)
)
ENGINE = S3('https://storage.yandexcloud.net/ssb-dbgen/customer.tbl', 'CSV')
{% endset %}
{% set sql2 %}
CREATE TABLE IF NOT EXISTS {{ var('schema') }}.src_lineorder
(
LO_ORDERKEY UInt32,
LO_LINENUMBER UInt8,
LO_CUSTKEY UInt32,
LO_PARTKEY UInt32,
LO_SUPPKEY UInt32,
LO_ORDERDATE Date,
LO_ORDERPRIORITY LowCardinality(String),
LO_SHIPPRIORITY UInt8,
LO_QUANTITY UInt8,
LO_EXTENDEDPRICE UInt32,
LO_ORDTOTALPRICE UInt32,
LO_DISCOUNT UInt8,
LO_REVENUE UInt32,
LO_SUPPLYCOST UInt32,
LO_TAX UInt8,
LO_COMMITDATE Date,
LO_SHIPMODE LowCardinality(String)
)
ENGINE = S3('https://storage.yandexcloud.net/ssb-dbgen/lineorder.tbl', 'CSV')
{% endset %}
{% set sql3 %}
CREATE TABLE IF NOT EXISTS {{ var('schema') }}.src_part
(
P_PARTKEY UInt32,
P_NAME String,
P_MFGR LowCardinality(String),
P_CATEGORY LowCardinality(String),
P_BRAND LowCardinality(String),
P_COLOR LowCardinality(String),
P_TYPE LowCardinality(String),
P_SIZE UInt8,
P_CONTAINER LowCardinality(String)
)
ENGINE = S3('https://storage.yandexcloud.net/otus-dwh/dbgen/part.tbl', 'CSV')
;
{% endset %}
{% set sql4 %}
CREATE TABLE IF NOT EXISTS {{ var('schema') }}.src_supplier
(
S_SUPPKEY UInt32,
S_NAME String,
S_ADDRESS String,
S_CITY LowCardinality(String),
S_NATION LowCardinality(String),
S_REGION LowCardinality(String),
S_PHONE String
)
ENGINE = S3('https://storage.yandexcloud.net/otus-dwh/dbgen/supplier.tbl', 'CSV')
;
{% endset %}
{% for i in [sql1, sql2, sql3, sql4] %}
{% do run_query(i) %}
{% endfor %}
{%- endmacro %}