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 702361b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 49 deletions.
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 702361b

Please sign in to comment.