Skip to content

Commit cbcf287

Browse files
authored
Handle deprecations in deduplicate macro (#673)
resolves #668
1 parent a041bb7 commit cbcf287

File tree

4 files changed

+2
-63
lines changed

4 files changed

+2
-63
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

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

2122
## Under the hood
2223
- Fully remove varargs usage in surrogate_key and safe_add ([#674](https://github.com/dbt-labs/dbt-utils/pull/674))

integration_tests/models/sql/schema.yml

-5
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ models:
185185
- dbt_utils.equality:
186186
compare_model: ref('data_deduplicate_expected')
187187

188-
- name: test_deduplicate_deprecated
189-
tests:
190-
- dbt_utils.equality:
191-
compare_model: ref('data_deduplicate_expected')
192-
193188
- name: test_not_empty_string_failing
194189
columns:
195190
- name: string_trim_whitespace_true

integration_tests/models/sql/test_deduplicate_deprecated.sql

-22
This file was deleted.

macros/sql/deduplicate.sql

+1-36
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,4 @@
1-
{%- macro deduplicate(relation, partition_by, order_by=none, relation_alias=none) -%}
2-
3-
{%- set error_message_group_by -%}
4-
Warning: the `group_by` parameter of the `deduplicate` macro is no longer supported and will be deprecated in a future release of dbt-utils.
5-
Use `partition_by` instead.
6-
The {{ model.package_name }}.{{ model.name }} model triggered this warning.
7-
{%- endset -%}
8-
9-
{% if kwargs.get('group_by') %}
10-
{%- do exceptions.warn(error_message_group_by) -%}
11-
{%- endif -%}
12-
13-
{%- set error_message_order_by -%}
14-
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.
15-
Supply a non-null value for `order_by` instead.
16-
The {{ model.package_name }}.{{ model.name }} model triggered this warning.
17-
{%- endset -%}
18-
19-
{% if not order_by %}
20-
{%- do exceptions.warn(error_message_order_by) -%}
21-
{%- endif -%}
22-
23-
{%- set error_message_alias -%}
24-
Warning: the `relation_alias` parameter of the `deduplicate` macro is no longer supported and will be deprecated in a future release of dbt-utils.
25-
If you were using `relation_alias` to point to a CTE previously then you can now pass the alias directly to `relation` instead.
26-
The {{ model.package_name }}.{{ model.name }} model triggered this warning.
27-
{%- endset -%}
28-
29-
{% if relation_alias %}
30-
{%- do exceptions.warn(error_message_alias) -%}
31-
{%- endif -%}
32-
33-
{% set partition_by = partition_by or kwargs.get('group_by') %}
34-
{% set relation = relation_alias or relation %}
35-
{% set order_by = order_by or "'1'" %}
36-
1+
{%- macro deduplicate(relation, partition_by, order_by) -%}
372
{{ return(adapter.dispatch('deduplicate', 'dbt_utils')(relation, partition_by, order_by)) }}
383
{% endmacro %}
394

0 commit comments

Comments
 (0)