diff --git a/dbt_project.yml b/dbt_project.yml index b597dad..e5dbb51 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -6,7 +6,7 @@ version: "1.0.0" config-version: 2 # This setting configures which "profile" dbt uses for this project. -profile: "snowflake" +profile: "bigquery" require-dbt-version: ">=1.6.0rc2" # These configurations specify where dbt should look for different types of files. diff --git a/models/marts/customer360/customers.sql b/models/marts/customer360/customers.sql index 36db145..24347f8 100644 --- a/models/marts/customer360/customers.sql +++ b/models/marts/customer360/customers.sql @@ -27,7 +27,7 @@ order_summary as ( min(orders.ordered_at) as first_ordered_at, max(orders.ordered_at) as last_ordered_at, sum(order_items.product_price) as lifetime_spend_pretax, - sum(orders.order_total) as lifetime_spend + sum(orders.order_total_) as lifetime_spend from orders_table as orders diff --git a/models/marts/customer360/order_items.yml b/models/marts/customer360/order_items.yml index f1e4482..05cde6b 100644 --- a/models/marts/customer360/order_items.yml +++ b/models/marts/customer360/order_items.yml @@ -21,6 +21,11 @@ semantic_models: type: time type_params: time_granularity: day + - name: ordered_at_test + expr: cast(ordered_at as DATETIME) + type: time + type_params: + time_granularity: day - name: is_food_item type: categorical - name: is_drink_item @@ -69,12 +74,16 @@ metrics: measure: name: revenue fill_nulls_with: 0 + join_to_timespine: true - name: order_cost description: Sum of cost for each order item. label: Order Cost type: simple type_params: - measure: order_cost + measure: + name: order_cost + join_to_timespine: true + fill_nulls_with: 0 - name: median_revenue description: The median revenue for each order item. Excludes tax. type: simple @@ -164,3 +173,20 @@ saved_queries: - name: weekly_revenue config: export_as: table + - name: order_cost_time_spine_test + query_params: + metrics: + - revenue + group_by: + - TimeDimension('metric_time', 'day') + where: + # - "{{TimeDimension('metric_time', 'day')}} >= + # CASE + # WHEN EXTRACT(day FROM CURRENT_DATE AT TIME ZONE 'America/New_York') > 14 THEN + # DATEADD(month, 1, DATE_TRUNC(month, CURRENT_DATE AT TIME ZONE 'America/New_York')) + # WHEN EXTRACT(day FROM CURRENT_DATE AT TIME ZONE 'America/New_York') <= 14 THEN + # DATE_TRUNC(month, CURRENT_DATE AT TIME ZONE 'America/New_York') + # ELSE NULL + # END" + # - "{{TimeDimension('order_item__ordered_at_test', 'month')}}>= '2020-01-01'" + - "{{TimeDimension('metric_time', 'month')}}>= '2020-01-01'" \ No newline at end of file diff --git a/models/marts/customer360/orders.yml b/models/marts/customer360/orders.yml index ccee230..80d90b7 100644 --- a/models/marts/customer360/orders.yml +++ b/models/marts/customer360/orders.yml @@ -60,7 +60,7 @@ semantic_models: expr: customer_id dimensions: - name: ordered_at - expr: cast(ordered_at as DATE) + expr: cast(ordered_at as datetime) type: time type_params: time_granularity: day diff --git a/models/staging/stg_orders.sql b/models/staging/stg_orders.sql index 0eaf6ae..4f645d1 100644 --- a/models/staging/stg_orders.sql +++ b/models/staging/stg_orders.sql @@ -18,7 +18,7 @@ renamed as ( customer as customer_id, ---------- numerics - (order_total / 100.0) as order_total, + (order_total / 100.0) as order_total_, (tax_paid / 100.0) as tax_paid, ---------- timestamps