Bug: Contract validation fails when join_use_nulls is configured via query_settings
Description
When join_use_nulls=1 is configured through query_settings in a model config, dbt contract validation incorrectly fails for a nullable column.
The same model passes contract validation when join_use_nulls is specified directly in the query instead.
Reproduction
my_model.sql
{{
config(
order_by='id',
query_settings={
'join_use_nulls': 1
}
)
}}
select
id,
last_value
from (
select 1 as id
) t1
left join (
select
1 as id,
max(value) as last_value
from (
select 1 as value
)
where value = 2
) t2
on t1.id = t2.id
my_model.yml
models:
- name: my_model
config:
contract:
enforced: true
columns:
- name: id
data_type: UInt8
- name: last_value
data_type: Nullable(UInt8)
Expected behavior
Contract validation should succeed because last_value is returned as Nullable(UInt8) when join_use_nulls=1 is enabled.
Actual behavior
Contract validation fails due to a type mismatch.
Additional information
If join_use_nulls is specified directly in the model query instead of through query_settings, contract validation succeeds.
Environment
- dbt version: 1.10.19
- dbt-clickhouse version: 1.10.0
- ClickHouse version: 25.4
Bug: Contract validation fails when
join_use_nullsis configured viaquery_settingsDescription
When
join_use_nulls=1is configured throughquery_settingsin a model config, dbt contract validation incorrectly fails for a nullable column.The same model passes contract validation when
join_use_nullsis specified directly in the query instead.Reproduction
my_model.sql{{ config( order_by='id', query_settings={ 'join_use_nulls': 1 } ) }} select id, last_value from ( select 1 as id ) t1 left join ( select 1 as id, max(value) as last_value from ( select 1 as value ) where value = 2 ) t2 on t1.id = t2.idmy_model.ymlExpected behavior
Contract validation should succeed because
last_valueis returned asNullable(UInt8)whenjoin_use_nulls=1is enabled.Actual behavior
Contract validation fails due to a type mismatch.
Additional information
If
join_use_nullsis specified directly in the model query instead of throughquery_settings, contract validation succeeds.Environment