Skip to content

Commit

Permalink
Fix stg_orders as BQ does not support lateral column aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenwindflower committed Mar 29, 2024
1 parent 7cffd82 commit 0d7d1b6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions models/staging/stg_orders.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ renamed as (
subtotal + tax_paid as order_total_cents,
{{ cents_to_dollars('subtotal') }} as subtotal,
{{ cents_to_dollars('tax_paid') }} as tax_paid,
{{ cents_to_dollars('order_total_cents') }} as order_total,

---------- timestamps
{{ dbt.date_trunc('day','ordered_at') }} as ordered_at

from source

),

-- BigQuery does not support lateral column aliases so we need a separate CTE
add_total as (

select
*,
{{ cents_to_dollars('order_total_cents') }} as order_total

from renamed

)

select * from renamed
select * from add_total

0 comments on commit 0d7d1b6

Please sign in to comment.