Databricks Data Engineer Associate Question 395
Single answerYou are working with a Delta Lake table in Databricks that enforces a NOT NULL constraint on a specific column. While inserting data into this table, one of the rows violates the NOT NULL constraint. What is the default behavior of Delta Lake when this constraint violation occurs?
- A
The query fails, and no rows are written to the table.
- B
The query succeeds, but the violating row is skipped.
- C
The query succeeds, but a warning is logged for the violating row.
- D
The query fails, but the rows that do not violate constraints are written to the table.
Show answer and explanation
Correct answer: A
Explanation
Delta Lake enforces constraints such as NOT NULL strictly to maintain data integrity. If any row in an insert or write operation violates a constraint, the default behavior is to fail the entire query without writing any data to the table. This ensures that the table remains consistent and adheres to the defined constraints.
- A. Correct.
Correct. Delta Lake enforces constraints strictly, and if a constraint violation occurs (such as a NOT NULL violation), the entire query fails, and no rows are written to the table by default.
- B. Incorrect.
Incorrect. Delta Lake does not skip violating rows by default; instead, the query fails entirely.
- C. Incorrect.
Incorrect. Delta Lake does not log a warning and proceed with the query for constraint violations, it enforces constraints strictly, leading to a failure.
- D. Incorrect.
Incorrect. Delta Lake does not allow partial writes when a constraint is violated. The entire query fails if any row violates the constraint.