Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle deprecations in deduplicate macro #673

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 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))

## Fixes
- Better handling of whitespaces in the star macro ([#651](https://github.com/dbt-labs/dbt-utils/pull/651))
Expand All @@ -27,7 +28,7 @@
- [@epapineau](https://github.com/epapineau) (#634)
- [@courentin](https://github.com/courentin) (#651)
- [@sfc-gh-ancoleman](https://github.com/sfc-gh-ancoleman) (#660)
- [@miles170](https://github.com/miles170) (#671)
- [@miles170](https://github.com/miles170)
- [@emilyriederer](https://github.com/emilyriederer)

# dbt-utils v0.8.6
Expand Down
6 changes: 0 additions & 6 deletions integration_tests/models/sql/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,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 All @@ -218,4 +213,3 @@ models:
- assert_equal:
actual: actual
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