Skip to content

Commit

Permalink
Null safety for deduplicate when relation is not a CTE
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 committed Jul 31, 2023
1 parent d46676e commit fe03f43
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion macros/sql/deduplicate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ path: {}
{% set row_alias = kwargs.get('row_alias') %}
{% set columns = kwargs.get('columns') %}

{% if row_alias != None or columns != None %}
{% if relation.is_cte is defined and not relation.is_cte %}
{% set columns = dbt_utils.get_filtered_columns_in_relation(relation) %}
{{ dbt_utils._safe_deduplicate(relation, partition_by, order_by, columns=columns) }}
{% elif row_alias != None or columns != None %}
{{ dbt_utils._safe_deduplicate(relation, partition_by, order_by, row_alias=row_alias, columns=columns) }}
{% else %}
{{ dbt_utils._unsafe_deduplicate(relation, partition_by, order_by) }}
Expand Down

0 comments on commit fe03f43

Please sign in to comment.