Databricks Data Engineer Associate Question 393
Single answerYou have created a Delta table with a NOT NULL constraint on one of its columns. During a batch write operation, one of the rows violates this constraint by attempting to insert a NULL value. What is the default behavior in this situation?
- A
The batch write operation fails, and no data is written to the table.
- B
The batch write operation succeeds, but the row violating the constraint is skipped.
- C
The batch write operation succeeds, but the null value is replaced with a default value.
- D
The batch write operation partially completes, writing only the rows that do not violate the constraint.
Show answer and explanation
Correct answer: A
Explanation
Delta Lake enforces constraints like NOT NULL to ensure data integrity. If a constraint violation occurs during a batch write, Delta Lake's default behavior is to fail the entire operation and roll back any changes. This ensures that the table's data remains consistent and adheres to the defined constraints.
- A. Correct.
Correct: Delta Lake enforces constraints such as NOT NULL during batch write operations. If a constraint violation occurs, the entire operation fails, and no data is written to the table.
- B. Incorrect.
Incorrect: Delta Lake does not skip rows that violate constraints. The operation is entirely aborted upon encountering a constraint violation.
- C. Incorrect.
Incorrect: Delta Lake does not automatically replace null values or modify data to resolve constraint violations.
- D. Incorrect.
Incorrect: Delta Lake does not allow partial writes in the case of constraint violations. The entire batch write is rolled back.