You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A dbt generic test relationships doesn't work with ClickHouse DBMS.
For example, let's see the model:
schema.yml:
version: 2models:
- name: customerscolumns:
- name: id
- name: name
- name: orderscolumns:
- name: id
- name: good
- name: customer_idtests:
- relationships:
to: ref('customers')field: id
customers.sql:
SELECT1AS id, 'Alice'AS name
UNION ALLSELECT2, 'Bob'
A dbt generic test
relationships
doesn't work with ClickHouse DBMS.For example, let's see the model:
schema.yml:
customers.sql:
orders.sql:
There is an incorrect foreign key
customer_id=3
, butdbt test
passes that integrity test.Cause of that is ClickHouse default join behavior:
There is empty cells are filled with the default value, but not NULLs.
dbt macros
relationships
do same query and expects NULL cells.To set NULL for this cells set
join_use_nulls = 1
:With
join_use_nulls = 1
generic testrelationships
work as expected:ClickHouse allow to set settings by different ways:
My proposal: add a dispatched macro
test_relationships
in the dbt-clickhouse package, like this:Another way is set
join_use_nulls
for session, but it will affect other queries.Or, at least this behavior should be documented with README.
The text was updated successfully, but these errors were encountered: