CertLumen

Databricks Data Engineer Associate · Section 3 · 22% of the exam

Apply data quality checks and validation rules to ensure reliable Silver and Gold datasets.

One of the objectives of the Databricks Certified Data Engineer Associate exam, in the section “Data Transformation and Modeling”. Here is what it covers, the points to remember and a question to try.

What it covers

Enforce row-level rules with pipeline expectations (warn, drop, fail), protect tables with Delta NOT NULL and CHECK constraints, keep bad rows in quarantine, validate whole datasets with SQL, and watch tables with data quality monitoring.

Points to remember

  • Expectation syntax: CONSTRAINT name EXPECT (condition) [ON VIOLATION DROP ROW | FAIL UPDATE]; no clause = warn (row kept, counted).
  • Python: @dp.expect, @dp.expect_or_drop, @dp.expect_or_fail, plus @dp.expect_all… variants taking a dict of rules.
  • FAIL UPDATE stops the flow, requires manual intervention, and records no expectation metrics.
  • Metrics: pipeline UI Data quality tab or event log flow_progress → details:flow_progress.data_quality (passed/failed/dropped records).
  • Expectation conditions are row-level and deterministic: no aggregates, windows or subqueries — use a validation dataset for uniqueness.

Try a question

A rule states that order_id must be unique in silver_orders. The engineer tries CONSTRAINT unique_id EXPECT (count(*) OVER (PARTITION BY order_id) = 1) and the pipeline rejects it. What is the best way to enforce this rule inside the pipeline?

  1. AAdd a validation dataset that counts duplicate keys, with EXPECT (duplicate_keys = 0) ON VIOLATION FAIL UPDATE
  2. BDeclare PRIMARY KEY (order_id) on silver_orders so that Unity Catalog rejects duplicate rows on write
  3. CKeep the same window expression but change the action to ON VIOLATION DROP ROW to remove duplicates
  4. DSet the table property delta.constraints.unique_id to the window expression so that Delta enforces it
Show the answer

A. An expectation is a condition evaluated on each record on its own, so it cannot look across rows. A dataset-level rule such as uniqueness is enforced by computing the violations in a separate validation dataset, for example a materialized view SELECT count(*) AS duplicate_keys FROM (SELECT order_id FROM silver_orders GROUP BY order_id HAVING count(*) > 1), and putting a row-level expectation on that dataset's single result row.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson Data Quality & Validation teaches this objective (about 40 minutes), and 9 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 29 objectives · Next objective →