Skip to content

Commit

Permalink
Remove deprecated table argument from unpivot()
Browse files Browse the repository at this point in the history
resolves #670
  • Loading branch information
miles170 committed Sep 15, 2022
1 parent 064c2ab commit bc27c59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 49 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
- Remove deprecated table argument from unpivot ([#671](https://github.com/dbt-labs/dbt-utils/pull/671)

## 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) (#671)

# dbt-utils v0.8.6

Expand Down
32 changes: 0 additions & 32 deletions integration_tests/models/sql/test_unpivot_original_api.sql

This file was deleted.

21 changes: 4 additions & 17 deletions macros/sql/unpivot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,13 @@ Arguments:
value_name: Destination table column name for the pivoted values
#}

{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value', table=none) -%}
{{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name, table)) }}
{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}
{{ return(adapter.dispatch('unpivot', 'dbt_utils')(relation, cast_to, exclude, remove, field_name, value_name)) }}
{% endmacro %}

{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value', table=none) -%}
{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value') -%}

{% if table %}
{%- set error_message = '
Warning: the `unpivot` macro no longer accepts a `table` parameter. \
This parameter will be deprecated in a future release of dbt-utils. Use the `relation` parameter instead. \
The {}.{} model triggered this warning. \
'.format(model.package_name, model.name) -%}
{%- do exceptions.warn(error_message) -%}
{% endif %}

{% if relation and table %}
{{ exceptions.raise_compiler_error("Error: both the `relation` and `table` parameters were provided to `unpivot` macro. Choose one only (we recommend `relation`).") }}
{% elif not relation and table %}
{% set relation=table %}
{% elif not relation and not table %}
{% if not relation %}
{{ exceptions.raise_compiler_error("Error: argument `relation` is required for `unpivot` macro.") }}
{% endif %}

Expand Down

0 comments on commit bc27c59

Please sign in to comment.