Menu

Databricks UNIQUE and RELY: Validate the Promise Before Optimizing
📰

Databricks UNIQUE and RELY: Validate the Promise Before Optimizing

DEV Community: sql·Snigdh Sharma·6 days ago
#TopOc85F
#devtosql#devto#dev#databricks#null
Long article (876 words) — no AI summary yet.
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.