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
{{ message }}
Repository navigation
dbt sync: composite primary key test uses double-quoted identifiers, which Databricks/Spark read as string literals, so the test always fails #1713
For a schema with a composite primary key, datacontract dbt sync generates a singular test that quotes column names with double quotes. Databricks and Spark SQL read a double-quoted value as a string literal, not as an identifier. The query then groups every row under one constant tuple, so on any table with more than one row it returns exactly one row and the test fails. Data that is actually unique still fails.
Version
datacontract-cli 1.2.0. The same code is on main, so 1.2.4 is affected too.
_composite_pk_singular_test uses it for both the SELECT and GROUP BY lists. On Databricks/Spark, unless spark.sql.ansi.doubleQuotedIdentifiers is enabled, "machine_number" is the string 'machine_number'.
Workaround
Do not declare a composite primaryKey in the contract, and keep a dbt_utils.unique_combination_of_columns test in the model YAML.
Thanks for the report. Confirmed on Databricks, and it went further than the composite key test: the generated length, pattern and range tests were broken by the same double quotes, on BigQuery and Snowflake too.
#1714 switches these tests to bare column names, the same way dbt's own generic tests reference columns.
Activity
jschoedl commentedon Oct 8, 2026
Thanks for the report. Confirmed on Databricks, and it went further than the composite key test: the generated length, pattern and range tests were broken by the same double quotes, on BigQuery and Snowflake too.
#1714 switches these tests to bare column names, the same way dbt's own generic tests reference columns.