mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
Migrate Metrics from REP to FCT
This commit is contained in:
@@ -26,25 +26,21 @@ join_tables AS (
|
||||
create_metrics AS (
|
||||
SELECT
|
||||
*,
|
||||
{% for column_name in ["parent_company", "sub_company"] %}
|
||||
|
||||
CASE
|
||||
WHEN ROW_NUMBER() OVER (PARTITION BY join_tables.{{column_name}}_id ORDER BY join_tables.origin_warehouse_shipping_order_created_datetime) = 1 THEN 1
|
||||
WHEN ROW_NUMBER() OVER (PARTITION BY join_tables.parent_company_id ORDER BY join_tables.origin_warehouse_shipping_order_created_datetime) = 1 THEN 1
|
||||
ELSE 0
|
||||
END AS is_first_time_{{column_name}},
|
||||
END AS is_first_time_parent_company,
|
||||
|
||||
CASE
|
||||
WHEN join_tables.origin_warehouse_shipping_order_status = 'COMPLETED'
|
||||
AND
|
||||
MIN(IFF(join_tables.origin_warehouse_shipping_order_status = 'COMPLETED', join_tables.origin_warehouse_shipping_order_created_datetime, NULL))
|
||||
OVER (PARTITION BY join_tables.{{column_name}}_id)
|
||||
OVER (PARTITION BY join_tables.parent_company_id)
|
||||
= join_tables.origin_warehouse_shipping_order_created_datetime
|
||||
THEN 1
|
||||
ELSE 0
|
||||
END AS is_first_time_{{column_name}}_completed,
|
||||
{% endfor %}
|
||||
|
||||
-- temp debug, need make sure it do not have null in fct, cause cant add
|
||||
(ZEROIFNULL(total_package_cbm) + ZEROIFNULL(over_weight_cbm) + ZEROIFNULL(pallet_charge_cbm)) AS total_order_cbm,
|
||||
END AS is_first_time_parent_company_completed,
|
||||
|
||||
'{{ modules.datetime.datetime.now(modules.pytz.timezone("Asia/Kuala_Lumpur")) }}' AS _dbt_ran_datetime
|
||||
|
||||
|
||||
Reference in New Issue
Block a user