Originally published on Snigdh Sharma’s website .
Metadata can become a correctness dependency
Databricks' November 3 article explains how UNIQUE constraints describe alternative keys, including nullable and composite keys. Its current documentation lists UNIQUE as Public Preview for Unity Catalog Delta tables in Databricks SQL and Runtime 18.2 or later. Check the current requirements for your deployment before adopting the feature.
The important distinction is enforcement: primary keys, foreign keys, and UNIQUE constraints are informational in Databricks. Declaring one does not reject duplicates. NOT NULL and CHECK constraints belong to the enforced category. A familiar SQL keyword can therefore represent a different operational guarantee from the one your source database provides.
RELY changes what the optimizer may assume
NORELY is the default. With RELY, Databricks may use the constraint to rewrite queries; an invalid guarantee can consequently produce incorrect results.…