Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timespine debug #73

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion models/marts/customer360/customers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
28 changes: 27 additions & 1 deletion models/marts/customer360/order_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'"
2 changes: 1 addition & 1 deletion models/marts/customer360/orders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion models/staging/stg_orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading