Which TWO of the following statements are true regarding the use of Delta Lake constraints in Databricks SQL?
Trap 1: CHECK constraints are enforced on existing rows when initially…
Adding a CHECK constraint to an existing Delta table does not retroactively validate historical data. The constraint only applies to new writes or updates performed after the constraint is added. Consequently, existing invalid records in the table remain, which can still cause issues for queries expecting clean, compliant data.
Trap 2: NOT NULL constraints are automatically applied to all primary key…
In Databricks SQL, columns defined as primary keys are implicitly treated as NOT NULL. This architectural decision ensures that identifying records is always possible and avoids ambiguity during join operations or lookups, preventing null-related errors in relational logic. This consistency is fundamental for reliable data modeling in lakehouses.
Trap 3: Delta Lake constraints allow for automatic row-level data repair…
Delta Lake constraints are strictly validation mechanisms that block write operations upon failure. They do not possess auto-repair capabilities, such as filtering out bad rows or applying default values. Developers must handle data cleansing processes in the ETL pipeline before the data reaches the constraint-protected Delta table.
- A
CHECK constraints are enforced on existing rows when initially defined.
Why it fails: Adding a CHECK constraint to an existing Delta table does not retroactively validate historical data. The constraint only applies to new writes or updates performed after the constraint is added. Consequently, existing invalid records in the table remain, which can still cause issues for queries expecting clean, compliant data.
- B
CHECK constraints ensure data integrity by preventing invalid records during inserts or updates.
CHECK constraints define a boolean expression that must evaluate to true for every row in the table. If a write operation attempts to insert or update a row that violates the specified condition, the operation will fail, ensuring that only data meeting the business requirements persists in the table.
- C
NOT NULL constraints can be applied to columns already containing null values.
Attempting to apply a NOT NULL constraint to a column that currently contains null values will result in a failure. The table must be cleaned of all null values in that column before the constraint can be successfully added to the table schema, ensuring future writes maintain consistency.
- D
NOT NULL constraints are automatically applied to all primary key columns.
Why it fails: In Databricks SQL, columns defined as primary keys are implicitly treated as NOT NULL. This architectural decision ensures that identifying records is always possible and avoids ambiguity during join operations or lookups, preventing null-related errors in relational logic. This consistency is fundamental for reliable data modeling in lakehouses.
- E
Delta Lake constraints allow for automatic row-level data repair during violations.
Why it fails: Delta Lake constraints are strictly validation mechanisms that block write operations upon failure. They do not possess auto-repair capabilities, such as filtering out bad rows or applying default values. Developers must handle data cleansing processes in the ETL pipeline before the data reaches the constraint-protected Delta table.