Databricks Data Engineer Associate Question 397
Single answerYou are working with a Delta Lake table in Databricks that has a NOT NULL constraint on a column. During an insert operation, a NULL value is provided for that column. What is the default behavior of Delta Lake in this situation?
- A
The operation succeeds, but the NULL value is replaced with a default value in the column.
- B
The operation fails immediately, and no data is written to the table.
- C
The operation fails, but partial data gets written to the table without the invalid row.
- D
The operation succeeds, and the NULL value is written to the column despite the constraint.
Show answer and explanation
Correct answer: B
Explanation
Delta Lake enforces constraints, such as NOT NULL, by default, and any violation of these constraints during an operation will cause the operation to fail. No data will be written to the table to ensure data integrity and atomicity of the transaction.
- A. Incorrect.
Delta Lake does not replace invalid values with default values automatically. This is not the default behavior.
- B. Correct.
Delta Lake enforces constraints strictly, and the operation fails immediately when a constraint violation occurs. No data is written to the table, ensuring data integrity.
- C. Incorrect.
Delta Lake does not allow partial writes in the event of a constraint violation. The entire transaction is rolled back to maintain consistency.
- D. Incorrect.
Delta Lake ensures that constraints like NOT NULL are strictly enforced. It will not allow a NULL value to be written to a column with a NOT NULL constraint.