cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Foreign key constraint in a dlt pipeline

Mario_D
New Contributor III

As primary/foreign key constraints are now supported/available in Databricks, how are foreign key constraints handled in a dlt pipeline, i.e if a foreign key constraint is violated, is the record logged as a data quality issue and still added to the target table?

1 ACCEPTED SOLUTION

Accepted Solutions

szymon_dybczak
Esteemed Contributor III

Hi @Mario_D ,

I don't think primary/foreign constraint are supported by DLT. At least I can't find anything in documentation. But you obtain same result using DLT expectations:

Manage data quality with Delta Live Tables - Azure Databricks | Microsoft Learn

View solution in original post

2 REPLIES 2

szymon_dybczak
Esteemed Contributor III

Hi @Mario_D ,

I don't think primary/foreign constraint are supported by DLT. At least I can't find anything in documentation. But you obtain same result using DLT expectations:

Manage data quality with Delta Live Tables - Azure Databricks | Microsoft Learn

RCo
New Contributor III

Hi @Mario_D!

While primary & foreign key constraints are generally available in Databricks Runtime 15.2 and above, they are strictly informational only.

This means that a primary key will not prevent duplicates from being added to a table and a foreign key does not require the referenced value to exist in another table.

https://docs.databricks.com/en/tables/constraints.html#declare-primary-key-and-foreign-key-relations...

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now