Databricks Data Engineer Associate Question 399
Single answerA Delta table in your Databricks environment has a CHECK constraint to ensure that the 'quantity' column must always be greater than 0. While ingesting new data into this table, some rows violate this constraint. How will the table behave if the 'ON VIOLATION' clause is set to 'DROP ROW' instead of 'FAIL UPDATE'?
- A
The violating rows will be discarded during ingestion, and the remaining rows will be successfully written to the table.
- B
The violating rows will be written to the table with a warning, but the constraint will still apply to future updates.
- C
The entire transaction will fail, and no rows will be written to the table.
- D
The violating rows will be logged in a separate file, and the rest will be written to the table.
Show answer and explanation
Correct answer: A
Explanation
The 'ON VIOLATION DROP ROW' clause ensures that any rows violating the constraints are excluded from the write operation, allowing the remaining valid rows to be successfully written to the table. This contrasts with 'ON VIOLATION FAIL UPDATE', where the entire transaction would fail, and no rows would be written.
- A. Correct.
When 'ON VIOLATION DROP ROW' is used, any rows that violate the table constraints will be discarded, and only the valid rows will be written to the table.
- B. Incorrect.
This is incorrect because violating rows are not written to the table when 'ON VIOLATION DROP ROW' is specified. They are discarded instead.
- C. Incorrect.
This describes the behavior of 'ON VIOLATION FAIL UPDATE', where the entire transaction fails if there is a constraint violation.
- D. Incorrect.
While logging of errors may occur in some workflows, this specific behavior is not tied to the 'ON VIOLATION DROP ROW' clause.