dbt-labs/dbt-core

[Bug] Unit Test Failed When using quoted column in snowflake

chura-awashima opened this issue · 1 comments

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

In Snowflake

this is target model file sample.sql

SELECT 1 as "a", 'c' as "b" FROM {{ ref('stg') }}

and this is parent model file stg.sql

SELECT 'a' as id

the first unit test file

unit_tests:
  - name: sample_test
    description: "sample failed test"
    model: sample
    given:
      - input: ref('stg')
        rows:
            - {id: "a"}
    expect:
      rows:
        - {a: 1, b: 'c'}

I got an error

An error occurred during execution of unit test 'sample'. There may be an error in the unit test definition: check the data types.
   Database Error
    000904 (42000): SQL compilation error: error line 3 at position 4
    invalid identifier 'A'

OK, I want to use quoted column so change unittest to

unit_tests:
  - name: sample
    description: "sample failed test"
    model: sample
    given:
      - input: ref('stg')
        rows:
            - {id: "a"}
    expect:
      rows:
        - {"a": 1, "b": 'c'}

but got same error.

Expected Behavior

I want use expect column such like "a"

Steps To Reproduce

  1. create stg model
  2. create sample model
  3. dbt run
  4. dbt test

Relevant log output

No response

Environment

- OS: Mac 14.1.1
- Python: 3.11.4
- dbt: 1.8.0 snowflake 1.8.0

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

Thanks for reporting this @chura-awashima !

This looks the same as dbt-labs/dbt-adapters#205 to me, so I'm going to close this one as a duplicate.