dbt-labs / dbt-labs/jaffle-shop
Order date handling is wrong causing order numbers to be non-deterministic
- Dominant language
- No language data
- Stars
- 356
- Forks
- 592
- PR merge metrics
- No merged PRs in 30d
Description
The raw order data provides the date and time of every order, but the staging model truncates the time portion using `{{ dbt.date_trunc('day','ordered_at') }}`. This removes the time of day the order was placed, which is very useful information for downstream analysis. It also causes the orders model to be non-deterministic because it calculates the customers order number as:
```
row_number() over (
partition by customer_id
order by ordered_at asc
) as customer_order_number
```
but if a customer places two orders on the same day, they will have the same ordered_at value (after its truncated to just the date) and the sort order -and therefore the customer_order_number - for customers with multiple orders on the same day are non-deterministic.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.