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

Snowflake SQL compilation error with quoted column names #141

Open
yannp opened this issue May 11, 2023 · 3 comments
Open

Snowflake SQL compilation error with quoted column names #141

yannp opened this issue May 11, 2023 · 3 comments
Labels
needs investigation This issue must be investigated

Comments

@yannp
Copy link

yannp commented May 11, 2023

Hi,
I encounter an issue I don't know how to handle. I get a SQL compilation error when running a test on my model when this model has quoted column names (in this example using "first name" and "last name" columns defined in a dummy jaffleshop model). A simple unit test looks like this:

{% call dbt_unit_testing.test('jaffle', 'name_is_correct') %}
  {% call dbt_unit_testing.mock_ref('jaffleshop', {"input_format": "sql"}) %}
    select 'bob' as "first name", 'bobson' as "last name"
  {% endcall %}

  {% call dbt_unit_testing.expect({"input_format": "sql"}) %}
    select 'bob' as "first name"
  {% endcall %}
{% endcall %}

Output gives invalid identifier '"FIRST NAME"'.
Thanks for your help!

@yannp
Copy link
Author

yannp commented May 15, 2023

Hello,
It seems that dbt-unit-testing is always using uppercase identifiers with Snowflake which breaks with quoted identifiers containing lowercase characters. Could you confirm?

@cdiniz cdiniz added the question Further information is requested label May 15, 2023
@psousa50 psousa50 added needs investigation This issue must be investigated question Further information is requested and removed question Further information is requested needs investigation This issue must be investigated labels May 27, 2023
@dhwdeca
Copy link

dhwdeca commented Jun 27, 2023

Just ran into this issue as well.
It's not so much that dbt-unit-testing is using uppercase, but Snowflake will translate any column identifier that isn't quoted as an uppercase identifier.
eg. This query works in Snowflake:
"with test as (
select 'something' as "QUOTED_COLUMN")
select quoted_column from test"
This one doesn't and gives the same error we're running into:
"with test as (
select 'something' as "quoted_column")
select quoted_column from test"

@dcallananILMN
Copy link

I tested out the PR 194 changes as well and this looks like it will fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This issue must be investigated
Projects
None yet
5 participants