Skip to content

Commit 7f9c503

Browse files
committed
Handle deprecations in deduplicate macro
resolves #668
1 parent 4a218df commit 7f9c503

File tree

4 files changed

+5
-65
lines changed

4 files changed

+5
-65
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
## Under the hood
1919
- Remove deprecated table argument from unpivot ([#671](https://github.com/dbt-labs/dbt-utils/pull/671))
2020

21+
## Under the hood
22+
- Handle deprecations in deduplicate macro ([#673](https://github.com/dbt-labs/dbt-utils/pull/673))
23+
2124
## Fixes
2225
- Better handling of whitespaces in the star macro ([#651](https://github.com/dbt-labs/dbt-utils/pull/651))
2326
- Fix to correct behavior in `mutually_exclusive_ranges` test in certain situations when `zero_length_range_allowed: true` and multiple ranges in a partition have the same value for `lower_bound_column`. ([[#659](https://github.com/dbt-labs/dbt-utils/issues/659)], [#660](https://github.com/dbt-labs/dbt-utils/pull/660))
@@ -27,7 +30,7 @@
2730
- [@epapineau](https://github.com/epapineau) (#634)
2831
- [@courentin](https://github.com/courentin) (#651)
2932
- [@sfc-gh-ancoleman](https://github.com/sfc-gh-ancoleman) (#660)
30-
- [@miles170](https://github.com/miles170) (#671)
33+
- [@miles170](https://github.com/miles170)
3134
- [@emilyriederer](https://github.com/emilyriederer)
3235

3336
# dbt-utils v0.8.6

integration_tests/models/sql/schema.yml

-6
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,6 @@ models:
188188
- dbt_utils.equality:
189189
compare_model: ref('data_deduplicate_expected')
190190

191-
- name: test_deduplicate_deprecated
192-
tests:
193-
- dbt_utils.equality:
194-
compare_model: ref('data_deduplicate_expected')
195-
196191
- name: test_not_empty_string_failing
197192
columns:
198193
- name: string_trim_whitespace_true
@@ -218,4 +213,3 @@ models:
218213
- assert_equal:
219214
actual: actual
220215
expected: expected
221-

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)