Skip to content

Commit

Permalink
Handle deprecations in deduplicate macro
Browse files Browse the repository at this point in the history
resolves #668
  • Loading branch information
miles170 committed Sep 15, 2022
1 parent 064c2ab commit b2a27c8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 64 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
## New features
- 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))

## Under the hood
- Handle deprecations in deduplicate macro ([#673](https://github.com/dbt-labs/dbt-utils/pull/673))

## Fixes
- Better handling of whitespaces in the star macro ([#651](https://github.com/dbt-labs/dbt-utils/pull/651))
- 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))
Expand All @@ -21,6 +24,7 @@
- [@christineberger](https://github.com/christineberger) (#624)
- [@courentin](https://github.com/courentin) (#651)
- [@sfc-gh-ancoleman](https://github.com/sfc-gh-ancoleman) (#660)
- [@miles170](https://github.com/miles170) (#673)

# dbt-utils v0.8.6

Expand Down
7 changes: 1 addition & 6 deletions integration_tests/models/sql/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,8 @@ 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_width_bucket
tests:
- assert_equal:
actual: actual
expected: expected
expected: expected
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 b2a27c8

Please sign in to comment.