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

Release/snowplow utils/0.16.7 #171

Merged
merged 3 commits into from
Jun 10, 2024
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
14 changes: 14 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
snowplow-utils 0.16.7 (2024-06-10)
---------------------------------------
## Summary
This release extends support for the combine_column_versions macro to support column prefixes not ending in a major version number (when used in combination with exclude column versions).

## Features
- Extend functionality of combine_column_versions

## Under the hood
- Update some of our test to pass with newer versions of dbt utils

## Upgrading
To upgrade, bump the package version in your `packages.yml` file.

snowplow-utils 0.16.6 (2024-05-24)
---------------------------------------
## Summary
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'snowplow_utils'
version: '0.16.6'
version: '0.16.7'
config-version: 2

require-dbt-version: [">=1.4.0", "<2.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'snowplow_utils_integration_tests'
version: '0.16.6'
version: '0.16.7'
config-version: 2

profile: 'integration_tests'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ with data as (
struct('Charlie' as f_name, 31 as numeric_col) as person_1_0_2,
struct('Dog the bounty' as f_name, 50 as numeric_col) as person_1_1_0,
struct('Dog the bounty' as f_name, 50 as numeric_col) as person_1_1_30,
struct('Dog the bounty' as f_name, 50 as numeric_col) as person_1_1_31
struct('Dog the bounty' as f_name, 50 as numeric_col) as person_1_1_31,
struct('a' as field_1, 2 as field_2) as test_1_0_0,
struct('b' as field_1, 3 as field_2) as test_1_1_0,
struct('b' as field_1, 3 as field_2) as test_1_1_15,
struct('c' as field_1, 4 as field_2) as test_new_1_0_0

)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ with prep as (
-- Test 5
coalesce(person_1_1_31.f_name, person_1_1_0.f_name, person_1_0_0.f_name) as f_name,
coalesce(person_1_1_31.numeric_col, person_1_1_0.numeric_col, person_1_0_0.numeric_col) as numeric_col,
-- Test 6
coalesce(test_1_1_15.field_1, test_1_0_0.field_1) as field_1,
coalesce(test_1_1_15.field_2, test_1_0_0.field_2) as field_2

from {{ ref('data_combine_column_versions') }}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0
column_prefix='person_1',
exclude_versions=['1_0_1', '1_0_2', '1_1_30']) %}

{% set test_6_actual = snowplow_utils.combine_column_versions(relation=ref('data_combine_column_versions'),
column_prefix='test',
exclude_versions=['new_1_0_0', '1_1_0']) %}

with prep as (
select
-- Test 1
Expand All @@ -50,7 +54,9 @@ with prep as (
-- Test 4
{{ test_4_actual|join(',') }} as product_volume,
-- Test 5
{{ test_5_actual|join(',') }}
{{ test_5_actual|join(',') }},
-- Test 6
{{ test_6_actual|join(',') }}

from {{ ref('data_combine_column_versions') }} a
)
Expand Down
1 change: 1 addition & 0 deletions integration_tests/models/utils/cross_db/cross_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ models:
tests:
- dbt_utils.equality:
compare_model: ref('expected_indexed_unnest')
exclude_columns: ['source_index']
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,30 @@ and you may not use this file except in compliance with the Snowplow Personal an
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/
#}
{% macro exclude_column_versions(columns, exclude_versions) %}
agnessnowplow marked this conversation as resolved.
Show resolved Hide resolved
{#
columns: an array of column names
exclude_versions: an array of versions (more generically a suffix) to exclude columns that end with this value
returns: filtered array of columns that do not end with any of the exclude versions.
#}
{% if not exclude_versions %}
{{ return(columns) }}
{% endif %}

{%- set filtered_columns_by_version = [] -%}

{%- set columns_to_exclude = [] -%}

{% for column in columns %}
{# Remove columns that end with the version we want to exclude #}
{% for version in exclude_versions %}
{% if not column.name.endswith(version) %}
{% do filtered_columns_by_version.append(column) %}
{% if column.name.endswith(version) %}
{% do columns_to_exclude.append(column) %}
{% endif %}
{% endfor %}
{% if not column in columns_to_exclude %}
{% do filtered_columns_by_version.append(column) %}
{% endif %}
{% endfor %}

{{ return(filtered_columns_by_version) }}

{% endmacro %}
Loading