Skip to content

Commit

Permalink
Merge pull request #72 from dbt-labs/rpourzand-datetime-pr
Browse files Browse the repository at this point in the history
Update orders.yml
  • Loading branch information
Jstein77 authored Jul 18, 2024
2 parents 3e28c59 + 8626676 commit 731c425
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions models/marts/customer360/customers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ semantic_models:
type: categorical
- name: first_ordered_at
type: time
expr: cast(first_ordered_at as DATE)
type_params:
time_granularity: day
- name: last_ordered_at
Expand Down
11 changes: 7 additions & 4 deletions models/marts/customer360/order_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ semantic_models:
expr: product_id
dimensions:
- name: ordered_at
expr: cast(ordered_at as DATETIME)
expr: cast(ordered_at as DATE)
type: time
type_params:
time_granularity: day
Expand All @@ -41,7 +41,10 @@ semantic_models:
expr: case when is_drink_item = 1 then product_price else 0 end
- name: median_revenue
description: The median revenue generated for each order item.
agg: median
agg: percentile
agg_params:
percentile: .5
use_approximate_percentile: True
expr: product_price

groups:
Expand Down Expand Up @@ -125,8 +128,8 @@ metrics:
type: cumulative
type_params:
measure: revenue
cumulative_type_params:
period_agg: last
# cumulative_type_params:
# period_agg: last

saved_queries:
- name: order_metrics
Expand Down
4 changes: 2 additions & 2 deletions 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: ordered_at
expr: cast(ordered_at as DATE)
type: time
type_params:
time_granularity: day
Expand Down Expand Up @@ -152,4 +152,4 @@ metrics:
type_params:
measure: order_count
window: 7 days
# // test
# // test
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dbt-metricflow[snowflake]==0.0.5
dbt-core
dbt-snowflake
pre-commit~=3.0.4
sqlfluff-templater-dbt~=2.0.0a5
sqlfluff~=2.0.0a5

0 comments on commit 731c425

Please sign in to comment.