← BuildandTeach Tech Tutorials posts

Published · By Henry Palma

Databricks Data Engineer Associate Practice Quiz, Lesson 11: Data Quality Checks, Expectations and Constraints

Practice quiz for the Databricks Data Engineer Associate exam, Lesson 11: warn, drop and fail expectations, CHECK constraints, and quarantining bad rows.

Databricks Data Engineer Associate Practice Quiz, Lesson 11: Data Quality Checks, Expectations and Constraints

Exam-style question: An expectation has no ON VIOLATION clause. A row fails the check. Does that row still reach the table? Yes. The default action is to warn, which records the failure and still writes the row. Use ON VIOLATION DROP ROW or FAIL UPDATE when a bad row must not land. This post is the practice quiz companion to Lesson 11 of the Databricks Data Engineer Associate exam prep series, in Section 3 of the August 2026 exam guide, Data Transformation and Modeling (22% of the exam).

Watch on YouTube

Video thumbnail
Video thumbnail

Watch the full Lesson 11: Data Quality Checks with Expectations and Constraints video if you want the walkthrough, then use this quiz to check yourself.

The written lesson companion is here: Lesson 11: Data Quality Checks with Expectations and Constraints.

The notebook and cheat sheet are in the A11 folder on GitHub. The PDF cheat sheet is in the same folder.

This is independent study material, not official Databricks training. The eight questions below are original practice items written by Build and Teach from the public exam guide and Databricks documentation. They are not real exam questions and are not affiliated with or endorsed by Databricks.

What this quiz covers

The exam asks you to apply validation rules so silver and gold stay reliable, and to know what happens when a row fails. In a Lakeflow pipeline, an expectation with no ON VIOLATION clause warns: the invalid record is written, and the violation is counted in the data quality metrics. ON VIOLATION DROP ROW, or dp.expectordrop in Python, drops the invalid records and logs the dropped count. ON VIOLATION FAIL UPDATE, or dp.expectorfail, stops the update and rolls it back, so none of the batch is written.

A table CHECK constraint behaves like fail, not like drop. If one row in an INSERT violates CHECK (amount >= 0), the whole statement fails, and the valid rows in that statement are not written either. Foreign keys in Unity Catalog are informational. They are not enforced, and an expectation cannot hold a subquery against another table. Join first, then expect that the matched key is not null.

Null handling in a DataFrame filter is a common trap. For a null amount, both amount >= 0 and NOT (amount >= 0) are null, not true, so a filter keeps neither row. Check isNull() first. When bad rows must stay out of silver, but someone still has to review them, and good rows must still load, quarantine the bad rows: tag a reason, write the clean set to silver, and write the bad rows to a separate table. Drop loses the rows. Fail loses the whole batch.

Pause the video when the timer shows, pick A, B, C or D, then check the answer. Seven or more of the eight questions right means you are ready for this section.

Practice questions from the quiz video

These are the eight questions from the quiz video, with answers and explanations.

Question 1

A pipeline table has EXPECT (amount >= 0) and no ON VIOLATION clause. An order arrives with amount -15.00. What happens?

  • A) The record is dropped
  • B) The update fails
  • C) The record is written and the violation is counted
  • D) The record moves to a quarantine table automatically

Answer: C. With no action, the default is warn. The invalid record is written to the target, and the violation is only counted in the data quality metrics.

Question 2

Which Python decorator drops invalid records before they are written?

  • A) dp.expect
  • B) dp.expectordrop
  • C) dp.expectorfail
  • D) dp.expect_all

Answer: B. expectordrop drops invalid records and logs the dropped count. Plain expect keeps them, and expectorfail stops the update.

Question 3

What does ON VIOLATION FAIL UPDATE do when one invalid record arrives?

  • A) Writes the valid records and drops the invalid one
  • B) Writes everything and logs a warning
  • C) Fails the update and rolls it back
  • D) Retries the record three times

Answer: C. The update stops and the table update is rolled back, so none of the batch is written. Someone has to fix the data before reprocessing.

Question 4

silver.orders has CHECK (amount >= 0). One INSERT writes order 5008 with -15.00 and order 5012 with 9.00. What is written?

  • A) Only 5012
  • B) Only 5008
  • C) Both rows
  • D) Neither row, the whole insert fails

Answer: D. A CHECK violation fails the whole transaction, so the valid order 5012 is not written either. A CHECK constraint acts like fail, not like drop.

Question 5

A DataFrame row has a NULL amount. Which filter keeps it: filter("amount >= 0") or filter("NOT (amount >= 0)")?

  • A) filter("amount >= 0")
  • B) filter("NOT (amount >= 0)")
  • C) Both of them
  • D) Neither of them

Answer: D. For a NULL amount, both conditions are NULL, not true. A filter keeps only rows where the condition is true, so check isNull() first.

Question 6

Five orders: one NULL customer_id, one amount -15.00, one for unknown customer 105. How many are written?

CREATE OR REFRESH STREAMING TABLE silver.orders_validated (
  CONSTRAINT valid_customer_id EXPECT (customer_id IS NOT NULL)
    ON VIOLATION DROP ROW,
  CONSTRAINT valid_amount EXPECT (amount >= 0) ON VIOLATION DROP ROW
) AS SELECT * FROM STREAM(bronze.orders_raw);
  • A) 2
  • B) 3
  • C) 5
  • D) 0

Answer: B. The two drop rules remove the NULL customer and the negative amount. The order for customer 105 still gets through, because no rule checks that the customer exists.

Question 7

An expectation uses customerid IN (SELECT customerid FROM silver.customers). What is the best fix?

  • A) Add ON VIOLATION DROP ROW to the same constraint
  • B) Declare a foreign key, because Databricks enforces it
  • C) Left join first, then EXPECT (matched_id IS NOT NULL)
  • D) Use dp.expect, because Python allows subqueries

Answer: C. Constraints cannot hold subqueries on other tables. Join first, so an unknown customer shows up as a NULL key. Foreign keys are informational, not enforced.

Question 8

Bad orders must stay out of silver, but someone must review and fix them. Good orders must still load. What fits best?

  • A) ON VIOLATION FAIL UPDATE
  • B) An expectation with no ON VIOLATION clause
  • C) Quarantine: tag a reason, split clean and bad tables
  • D) ON VIOLATION DROP ROW

Answer: C. Drop loses the rows and fail loses the whole batch. Quarantine keeps the clean set in silver and the bad rows, with a reason, in a separate table.

Practical tips

The memory trick from the video: warn writes. Drop drops. Fail stops.

If the question says invalid rows must not reach the table, a bare EXPECT is the wrong choice, because the default is warn. If someone must still review those rows, drop is also the wrong choice. That is the quarantine pattern.

Watch for a CHECK constraint on a multi-row insert. One bad row fails the whole transaction, including the good rows.

Key takeaways

  • A bare expectation warns: the bad row is written and the violation is counted.
  • DROP ROW or expectordrop removes invalid rows. FAIL UPDATE or expectorfail rolls back the whole update.
  • A CHECK constraint fails the entire statement, not just the bad row.
  • Filters do not keep nulls, because a null comparison is not true. Check isNull() first.
  • Expectations cannot use subqueries on other tables. Join first. Quarantine when bad rows must be reviewed and good rows must still load.

Check your understanding

1. A pipeline expectation is EXPECT (customerid IS NOT NULL) with no ON VIOLATION clause. A row arrives with a null customerid. What happens?

  • A) The row is dropped
  • B) The update fails and rolls back
  • C) The row is written, and the violation is counted
  • D) The row is moved to a quarantine table automatically

2. Which Python decorator stops the update and rolls it back when one invalid record arrives?

  • A) dp.expect
  • B) dp.expectordrop
  • C) dp.expectorfail
  • D) dp.expect_all

3. silver.orders has CHECK (amount >= 0). One INSERT includes a valid 20.00 order and a -5.00 order. What is written?

  • A) Only the 20.00 order
  • B) Both rows, with a warning on -5.00
  • C) Neither row, because the whole insert fails
  • D) Only the -5.00 order, in a quarantine table

4. You need to reject orders whose customer_id is not in silver.customers. What is the reliable pattern?

  • A) EXPECT (customerid IN (SELECT customerid FROM silver.customers))
  • B) Declare a foreign key, because Databricks enforces it
  • C) Left join to silver.customers first, then EXPECT (matched_id IS NOT NULL)
  • D) Use dp.expect, because Python allows subqueries in constraints

5. Bad orders must stay out of silver, good orders must still load, and someone must review the bad rows. What fits best?

  • A) ON VIOLATION FAIL UPDATE
  • B) An expectation with no ON VIOLATION clause
  • C) Quarantine: tag a reason, then split clean and bad tables
  • D) ON VIOLATION DROP ROW

Answer key

  1. C. With no action, the default is warn. The invalid record is written and the violation is counted.
  2. C. expectorfail stops the update and rolls it back. expect keeps the row, and expectordrop drops only the invalid ones.
  3. C. A CHECK violation fails the whole transaction, so the valid 20.00 order is not written either.
  4. C. Constraints cannot hold subqueries on other tables, and foreign keys are informational. Join first, then expect a non-null match.
  5. C. Fail loses the batch. A bare expectation still writes the bad rows to silver. Drop keeps them out of silver but does not keep them for review. Quarantine does both.

Have an idea, question, or feedback?

We'd genuinely like to hear from you.