Hi, I can’t run unit tests when the model has case-sensitive column names. Is this a known issue?
I’ve tried the unit tests using CSV and SQL formats without success. The only way it works is if I rename the model column names from CountryCode and CountryName to country_code and country_name.
Input reference country_codes table:
country_code,country_name
US,United States
CA,Canada
GB,United Kingdom
The model transformation:
with codes as (
select * from {{ ref('country_codes') }}
)
select
codes.country_code as "CountryCode",
codes.country_name as "CountryName"
from codes
limit 1
The example model transformation output:
CountryCode,CountryName
US,United States
The unit test that doesn’t support case-sensitive column names:
unit_tests:
- name: test_is_valid_country
description: "Check if the country is valid"
model: example
given:
- input: ref('country_codes')
rows:
- {country_code: US, country_name: United States}
expect:
rows:
- {"CountryCode": US, "CountryName": United States}
The error I get:
Runtime Error in unit_test test_is_valid_country (models/_models.yml)
An error occurred during execution of unit test 'test_is_valid_country'. There may be an error in the unit test definition: check the data types.
Database Error
column "countrycode" does not exist
LINE 5: CountryCode,CountryName, 'actual' as "actual_or_expected...
^
HINT: Perhaps you meant to reference the column "_dbt_internal_unit_test_actual.CountryCode".