Open ClauPet opened 1 month ago
Thanks for reporting this @ClauPet !
I can't replicate this because we set enable_case_sensitive_identifier
to true
in our cluster’s parameter group via the Amazon Redshift console.
But I absolutely believe you are experiencing this because I've seen the unfortunate consequences of Redshift's default behavior of ignoring quoted identifiers first-hand before. See below for example code that I think would reproduce this when enable_case_sensitive_identifier=false
(default).
The most direct way to overcome this to to set enable_case_sensitive_identifier
to true
, but I'm assuming that isn't an option for you.
In the meantime, I'm going to transfer this to the dbt-redshift
repo because I don't think this affects any other dbt adapters.
Create these files:
models/test.sql
select 'A' as column_name union all
select 'B' as column_name
models/test.yml
models:
- name: test
columns:
- name: column_name
tests:
- accepted_values:
values: ['A', 'B', 'C']
Run these commands:
dbt run --select test
dbt test --select test --store-failures
dbt test --select test --store-failures
Is this a new bug in dbt-core?
Current Behavior
I have the following dbt model:
test.sql
test.yml
After creating the model, I run the test doing
dbt test --select test --store_failures
. An empty table namedaccepted_values_test_column_name__a__b__c
is created in thedbt_test__audit
schema of my Redshift database. The second time I run the exact same command I get a compilation error saying that there is not tableaccepted_values_test_column_name__A__B__C
.Redshift by default uses case insensitive identifiers, e.g. table names. I know I could get around this by adding a custom lower case test names. However, this is not desirable with the amount of accepted values tests I have.
Expected Behavior
I would expect dbt to know of the case insensitivity of Redshift identifiers and not try to crate a table
accepted_values_test_column_name__A__B__C
.Steps To Reproduce
dbt test --store-failures
twiceRelevant log output
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response