Skip to content

Commit

Permalink
Fix BigQuery name collision
Browse files Browse the repository at this point in the history
  • Loading branch information
judahrand committed May 16, 2022
1 parent 82ccd98 commit 5bd6743
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions macros/sql/deduplicate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ The {{ model.package_name }}.{{ model.name }} model triggered this warning.
#}
{%- macro bigquery__deduplicate(relation, partition_by, order_by) -%}

select
array_agg (
original
order by {{ order_by }}
limit 1
)[offset(0)].*
from {{ relation }} as original
group by {{ partition_by }}
select unique.*
from (
select
array_agg (
original
order by {{ order_by }}
limit 1
)[offset(0)] unique
from {{ relation }} original
group by {{ partition_by }}
)

{%- endmacro -%}

0 comments on commit 5bd6743

Please sign in to comment.