Skip to content

Commit

Permalink
Handle deprecations in deduplicate macro (#673)
Browse files Browse the repository at this point in the history
resolves #668
  • Loading branch information
miles170 authored Sep 19, 2022
1 parent a041bb7 commit cbcf287
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

## Under the hood
- Remove deprecated table argument from unpivot ([#671](https://github.com/dbt-labs/dbt-utils/pull/671))
- Handle deprecations in deduplicate macro ([#673](https://github.com/dbt-labs/dbt-utils/pull/673))

## Under the hood
- Fully remove varargs usage in surrogate_key and safe_add ([#674](https://github.com/dbt-labs/dbt-utils/pull/674))
Expand Down
5 changes: 0 additions & 5 deletions integration_tests/models/sql/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ models:
- dbt_utils.equality:
compare_model: ref('data_deduplicate_expected')

- name: test_deduplicate_deprecated
tests:
- dbt_utils.equality:
compare_model: ref('data_deduplicate_expected')

- name: test_not_empty_string_failing
columns:
- name: string_trim_whitespace_true
Expand Down
22 changes: 0 additions & 22 deletions integration_tests/models/sql/test_deduplicate_deprecated.sql

This file was deleted.

37 changes: 1 addition & 36 deletions macros/sql/deduplicate.sql
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
{%- macro deduplicate(relation, partition_by, order_by=none, relation_alias=none) -%}

{%- set error_message_group_by -%}
Warning: the `group_by` parameter of the `deduplicate` macro is no longer supported and will be deprecated in a future release of dbt-utils.
Use `partition_by` instead.
The {{ model.package_name }}.{{ model.name }} model triggered this warning.
{%- endset -%}

{% if kwargs.get('group_by') %}
{%- do exceptions.warn(error_message_group_by) -%}
{%- endif -%}

{%- set error_message_order_by -%}
Warning: `order_by` as an optional parameter of the `deduplicate` macro is no longer supported and will be deprecated in a future release of dbt-utils.
Supply a non-null value for `order_by` instead.
The {{ model.package_name }}.{{ model.name }} model triggered this warning.
{%- endset -%}

{% if not order_by %}
{%- do exceptions.warn(error_message_order_by) -%}
{%- endif -%}

{%- set error_message_alias -%}
Warning: the `relation_alias` parameter of the `deduplicate` macro is no longer supported and will be deprecated in a future release of dbt-utils.
If you were using `relation_alias` to point to a CTE previously then you can now pass the alias directly to `relation` instead.
The {{ model.package_name }}.{{ model.name }} model triggered this warning.
{%- endset -%}

{% if relation_alias %}
{%- do exceptions.warn(error_message_alias) -%}
{%- endif -%}

{% set partition_by = partition_by or kwargs.get('group_by') %}
{% set relation = relation_alias or relation %}
{% set order_by = order_by or "'1'" %}

{%- macro deduplicate(relation, partition_by, order_by) -%}
{{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}
{% endmacro %}

Expand Down

0 comments on commit cbcf287

Please sign in to comment.