Skip to content

Commit

Permalink
configure raw layer for greenplum
Browse files Browse the repository at this point in the history
  • Loading branch information
kzzzr committed Oct 12, 2021
1 parent bba7437 commit dfc5866
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions models/raw_stage/raw_inventory.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ SELECT
d.N_REGIONKEY AS SUPPLIER_REGION_KEY,
e.R_NAME AS SUPPLIER_REGION_NAME,
e.R_COMMENT AS SUPPLIER_REGION_COMMENT
FROM {{ source('tpch_sample', 'PARTSUPP') }} AS a
LEFT JOIN {{ source('tpch_sample', 'SUPPLIER') }} AS b
FROM {{ source('tpch_sample', 'partsupp') }} AS a
LEFT JOIN {{ source('tpch_sample', 'supplier') }} AS b
ON a.PS_SUPPKEY = b.S_SUPPKEY
LEFT JOIN {{ source('tpch_sample', 'PART') }} AS c
LEFT JOIN {{ source('tpch_sample', 'part') }} AS c
ON a.PS_PARTKEY = c.P_PARTKEY
LEFT JOIN {{ source('tpch_sample', 'NATION') }} AS d
LEFT JOIN {{ source('tpch_sample', 'nation') }} AS d
ON b.S_NATIONKEY = d.N_NATIONKEY
LEFT JOIN {{ source('tpch_sample', 'REGION') }} AS e
LEFT JOIN {{ source('tpch_sample', 'region') }} AS e
ON d.N_REGIONKEY = e.R_REGIONKEY
JOIN {{ ref('raw_orders') }} AS f
ON a.PS_PARTKEY = f.PARTKEY AND a.PS_SUPPKEY=f.SUPPLIERKEY
Expand Down
20 changes: 10 additions & 10 deletions models/raw_stage/raw_orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ SELECT
d.N_COMMENT AS CUSTOMER_NATION_COMMENT,
e.R_NAME AS CUSTOMER_REGION_NAME,
e.R_COMMENT AS CUSTOMER_REGION_COMMENT
FROM {{ source('tpch_sample', 'ORDERS') }} AS b
LEFT JOIN {{ source('tpch_sample', 'LINEITEM') }} AS a
FROM {{ source('tpch_sample', 'orders') }} AS b
LEFT JOIN {{ source('tpch_sample', 'lineitem') }} AS a
ON a.L_ORDERKEY = b.O_ORDERKEY
LEFT JOIN {{ source('tpch_sample', 'CUSTOMER') }} AS c
LEFT JOIN {{ source('tpch_sample', 'customer') }} AS c
ON b.O_CUSTKEY = c.C_CUSTKEY
LEFT JOIN {{ source('tpch_sample', 'NATION') }} AS d
LEFT JOIN {{ source('tpch_sample', 'nation') }} AS d
ON c.C_NATIONKEY = d.N_NATIONKEY
LEFT JOIN {{ source('tpch_sample', 'REGION') }} AS e
LEFT JOIN {{ source('tpch_sample', 'region') }} AS e
ON d.N_REGIONKEY = e.R_REGIONKEY
LEFT JOIN {{ source('tpch_sample', 'PART') }} AS g
LEFT JOIN {{ source('tpch_sample', 'part') }} AS g
ON a.L_PARTKEY = g.P_PARTKEY
LEFT JOIN {{ source('tpch_sample', 'SUPPLIER') }} AS h
LEFT JOIN {{ source('tpch_sample', 'supplier') }} AS h
ON a.L_SUPPKEY = h.S_SUPPKEY
LEFT JOIN {{ source('tpch_sample', 'NATION') }} AS j
LEFT JOIN {{ source('tpch_sample', 'nation') }} AS j
ON h.S_NATIONKEY = j.N_NATIONKEY
LEFT JOIN {{ source('tpch_sample', 'REGION') }} AS k
LEFT JOIN {{ source('tpch_sample', 'region') }} AS k
ON j.N_REGIONKEY = k.R_REGIONKEY
WHERE b.O_ORDERDATE = TO_DATE('{{ var('load_date') }}')
WHERE b.O_ORDERDATE = '{{ var('load_date') }}'::DATE
12 changes: 6 additions & 6 deletions models/raw_stage/raw_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ SELECT
b.O_ORDERKEY AS ORDER_ID,
b.O_CUSTKEY AS CUSTOMER_ID,
b.O_ORDERDATE AS ORDER_DATE,
DATEADD(DAY, 20, b.O_ORDERDATE) AS TRANSACTION_DATE,
TO_NUMBER(RPAD(CONCAT(b.O_ORDERKEY, b.O_CUSTKEY, TO_CHAR(b.O_ORDERDATE, 'YYYYMMDD')), 24, '0')) AS TRANSACTION_NUMBER,
(b.O_ORDERDATE + 20 * INTERVAL '1 day') AS TRANSACTION_DATE,
(RPAD(CONCAT(b.O_ORDERKEY, b.O_CUSTKEY, TO_CHAR(b.O_ORDERDATE, 'YYYYMMDD')), 24, '0'))::NUMERIC AS TRANSACTION_NUMBER,
b.O_TOTALPRICE AS AMOUNT,
CAST(
CASE ABS(MOD(RANDOM(1), 2)) + 1
CASE ((ABS(RANDOM()::INT % 2)) + 1)
WHEN 1 THEN 'DR'
WHEN 2 THEN 'CR'
END AS VARCHAR(2)) AS TYPE
FROM {{ source('tpch_sample', 'ORDERS') }} AS b
LEFT JOIN {{ source('tpch_sample', 'CUSTOMER') }} AS c
FROM {{ source('tpch_sample', 'orders') }} AS b
LEFT JOIN {{ source('tpch_sample', 'customer') }} AS c
ON b.O_CUSTKEY = c.C_CUSTKEY
WHERE b.O_ORDERDATE = TO_DATE('{{ var('load_date') }}')
WHERE b.O_ORDERDATE = '{{ var('load_date') }}'::DATE

0 comments on commit dfc5866

Please sign in to comment.