forked from kzzzr/dbt_clickhouse_lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf_lineorder_flat.sql
70 lines (63 loc) · 1.37 KB
/
f_lineorder_flat.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
{{
config (
engine='MergeTree()',
order_by=['L_SHIPDATE', 'L_ORDERKEY'],
partition_by='toYear(L_SHIPDATE)'
)
}}
SELECT
L_ITEMKEY
, L_ORDERKEY
, L_PARTKEY
, L_SUPPKEY
, L_LINENUMBER
, L_QUANTITY
, L_EXTENDEDPRICE
, L_DISCOUNT
, L_TAX
, L_RETURNFLAG
, L_LINESTATUS
, L_SHIPDATE
, L_COMMITDATE
, L_RECEIPTDATE
, L_SHIPINSTRUCT
, L_SHIPMODE
, L_COMMENT
, O_ORDERKEY
, O_CUSTKEY
, O_ORDERSTATUS
, O_TOTALPRICE
, O_ORDERDATE
, O_ORDERPRIORITY
, O_CLERK
, O_SHIPPRIORITY
, O_COMMENT
, C_CUSTKEY
, C_NAME
, C_ADDRESS
, C_NATIONKEY
, C_PHONE
, C_ACCTBAL
, C_MKTSEGMENT
, C_COMMENT
, S_SUPPKEY
, S_NAME
, S_ADDRESS
, S_NATIONKEY
, S_PHONE
, S_ACCTBAL
, S_COMMENT
, P_PARTKEY
, P_NAME
, P_MFGR
, P_BRAND
, P_TYPE
, P_SIZE
, P_CONTAINER
, P_RETAILPRICE
, P_COMMENT
FROM {{ ref('stg_lineitem') }} AS l
INNER JOIN {{ ref('stg_orders') }} AS o ON o.O_ORDERKEY = l.L_ORDERKEY
INNER JOIN {{ ref('stg_customer') }} AS c ON c.C_CUSTKEY = o.O_CUSTKEY
INNER JOIN {{ ref('stg_supplier') }} AS s ON s.S_SUPPKEY = l.L_SUPPKEY
INNER JOIN {{ ref('stg_part') }} AS p ON p.P_PARTKEY = l.L_PARTKEY