Skip to content

Commit b2a27c8

Browse files
committed
Handle deprecations in deduplicate macro
resolves #668
1 parent 064c2ab commit b2a27c8

File tree

4 files changed

+6
-64
lines changed

4 files changed

+6
-64
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
## New features
1414
- New feature to omit the `source_column_name` column on the `union_relations` macro ([#331](https://github.com/dbt-labs/dbt-utils/issues/331), [#624](https://github.com/dbt-labs/dbt-utils/pull/624))
1515

16+
## Under the hood
17+
- Handle deprecations in deduplicate macro ([#673](https://github.com/dbt-labs/dbt-utils/pull/673))
18+
1619
## Fixes
1720
- Better handling of whitespaces in the star macro ([#651](https://github.com/dbt-labs/dbt-utils/pull/651))
1821
- 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))
@@ -21,6 +24,7 @@
2124
- [@christineberger](https://github.com/christineberger) (#624)
2225
- [@courentin](https://github.com/courentin) (#651)
2326
- [@sfc-gh-ancoleman](https://github.com/sfc-gh-ancoleman) (#660)
27+
- [@miles170](https://github.com/miles170) (#673)
2428

2529
# dbt-utils v0.8.6
2630

integration_tests/models/sql/schema.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,8 @@ models:
178178
- dbt_utils.equality:
179179
compare_model: ref('data_deduplicate_expected')
180180

181-
- name: test_deduplicate_deprecated
182-
tests:
183-
- dbt_utils.equality:
184-
compare_model: ref('data_deduplicate_expected')
185-
186181
- name: test_width_bucket
187182
tests:
188183
- assert_equal:
189184
actual: actual
190-
expected: expected
185+
expected: expected

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)