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

Enhancement: Allow dbt_utils.star() except list to be an type of capitalization #402

Closed
reidwil-jb opened this issue Aug 17, 2021 · 0 comments · Fixed by #403
Closed

Enhancement: Allow dbt_utils.star() except list to be an type of capitalization #402

reidwil-jb opened this issue Aug 17, 2021 · 0 comments · Fixed by #403

Comments

@reidwil-jb
Copy link
Contributor

reidwil-jb commented Aug 17, 2021

Issue:

Recently, I ran into an issue when trying to exclude columns from my dbt model using dbt_utils.star. This was happening because my command wasn't correctly formatted.

example.sql

select
  {{ dbt_utils.star(from=ref('my_model'), except=["column_a", "column_b"])
...

Because of this, my model was returning column_a and column_b because jinja2's list comparison doesn't find column_a to equal COLUMN_A (which makes sense).

Solution:

Cast both the input and except list to lower:

{%- if col.column|lower not in except|lower -%}

{%- if col.column not in except -%}


Note this is for snowflake specifically but this change should will work for every dbt supportive sql flavor.

reidwil-jb added a commit to reidwil-jb/dbt-utils that referenced this issue Aug 17, 2021
jasnonaz added a commit that referenced this issue Aug 30, 2021
* PR - lowercase `except` values in star()

resolves #402

* Update test_star.sql

* Update CHANGELOG.md

* Update test_star.sql

Co-authored-by: jasnonaz <jason.ganz64@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant