diff --git a/CHANGELOG.md b/CHANGELOG.md index e6dc7c15..fb5a161e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,17 @@ -# dbt-utils v0.8.0 +# dbt-utils v0.7.4 +🚨 This is a compatibility release in preparation for `dbt-core` v1.0.0 (🎉). Projects using dbt-utils 0.7.4 with dbt-core v1.0.0 can expect to see a deprecation warning. This will be resolved in dbt_utils v0.8.0. -# dbt-utils v0.7.4b1 -This is a compatibility release in preparation for `dbt-core` v1.0.0 (🎉). When dbt-core 1.0.0 hits release candidate status, we will release the final version of 0.7.4 +## Fixes +- `get_column_values()` now works correctly with mixed-quoting styles on Snowflake ([#424](https://github.com/dbt-labs/dbt-utils/issues/424), [#440](https://github.com/dbt-labs/dbt-utils/pull/440)) +- Remove extra semicolon in `insert_by_period` materialization that was causing errors ([#439](https://github.com/dbt-labs/dbt-utils/pull/439)) +- Swap `limit 0` out for `{{ limit_zero() }}` on the `slugify()` tests to allow for compatibility with [tsql-utils](https://github.com/dbt-msft/tsql-utils) ([#437](https://github.com/dbt-labs/dbt-utils/pull/437)) -🚨 Projects using utils 0.7.4 with Core 1.0.0 can expect to see a deprecation warning. This will be resolved in 0.8.0 of dbt_utils alongside the final version of 1.0.0. +## Contributors: +- [sean-rose](https://github.com/sean-rose) +- [@swanderz](https://github.com/swanderz) + +# dbt-utils v0.7.4b1 :rotating_light:🚨 We have renamed the `master` branch to `main`. If you have a local version of `dbt-utils`, you will need to update to the new branch. See the [GitHub docs](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-branches-in-your-repository/renaming-a-branch#updating-a-local-clone-after-a-branch-name-changes) for more details. ## Under the hood diff --git a/integration_tests/models/sql/test_get_column_values.sql b/integration_tests/models/sql/test_get_column_values.sql index 8e6f5b45..36214984 100644 --- a/integration_tests/models/sql/test_get_column_values.sql +++ b/integration_tests/models/sql/test_get_column_values.sql @@ -1,13 +1,13 @@ -{% set columns = dbt_utils.get_column_values(ref('data_get_column_values'), 'field', default=[], order_by="field") %} +{% set column_values = dbt_utils.get_column_values(ref('data_get_column_values'), 'field', default=[], order_by="field") %} {% if target.type == 'snowflake' %} select - {% for column in columns -%} + {% for val in column_values -%} - sum(case when field = '{{ column }}' then 1 else 0 end) as count_{{ column }} + sum(case when field = '{{ val }}' then 1 else 0 end) as count_{{ val }} {%- if not loop.last %},{% endif -%} {%- endfor %} @@ -17,9 +17,9 @@ from {{ ref('data_get_column_values') }} {% else %} select - {% for column in columns -%} + {% for val in column_values -%} - {{dbt_utils.safe_cast("sum(case when field = '" ~ column ~ "' then 1 else 0 end)", dbt_utils.type_string()) }} as count_{{ column }} + {{dbt_utils.safe_cast("sum(case when field = '" ~ val ~ "' then 1 else 0 end)", dbt_utils.type_string()) }} as count_{{ val }} {%- if not loop.last %},{% endif -%} {%- endfor %} diff --git a/integration_tests/tests/jinja_helpers/test_slugify.sql b/integration_tests/tests/jinja_helpers/test_slugify.sql index 07b184f7..c0839f59 100644 --- a/integration_tests/tests/jinja_helpers/test_slugify.sql +++ b/integration_tests/tests/jinja_helpers/test_slugify.sql @@ -1,7 +1,7 @@ {% if dbt_utils.slugify('!Hell0 world-hi') == 'hell0_world_hi' %} {# Return 0 rows for the test to pass #} - select 1 limit 0 + select 1 as col_name {{ limit_zero() }} {% else %} {# Return >0 rows for the test to fail #} - select 1 + select 1 as col_name {% endif %} diff --git a/macros/materializations/insert_by_period_materialization.sql b/macros/materializations/insert_by_period_materialization.sql index 9b43bdbb..851afa3d 100644 --- a/macros/materializations/insert_by_period_materialization.sql +++ b/macros/materializations/insert_by_period_materialization.sql @@ -102,7 +102,7 @@ {# Create an empty target table -#} {% call statement('main') -%} {%- set empty_sql = sql | replace("__PERIOD_FILTER__", 'false') -%} - {{create_table_as(False, target_relation, empty_sql)}}; + {{create_table_as(False, target_relation, empty_sql)}} {%- endcall %} {%- endif %} diff --git a/macros/sql/get_column_values.sql b/macros/sql/get_column_values.sql index 1f79a455..c2f65aff 100644 --- a/macros/sql/get_column_values.sql +++ b/macros/sql/get_column_values.sql @@ -9,9 +9,9 @@ {{ return('') }} {% endif %} - {%- set target_relation = adapter.get_relation(database=table.database, - schema=table.schema, - identifier=table.identifier) -%} + {# Not all relations are tables. Renaming for internal clarity without breaking functionality for anyone using named arguments #} + {# TODO: Change the method signature in a future 0.x.0 release #} + {%- set target_relation = table -%} {%- call statement('get_column_values', fetch_result=true) %}