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?
- AAdd a validation dataset that counts duplicate keys, with
EXPECT (duplicate_keys = 0) ON VIOLATION FAIL UPDATE - BDeclare
PRIMARY KEY (order_id)onsilver_ordersso that Unity Catalog rejects duplicate rows on write - CKeep the same window expression but change the action to
ON VIOLATION DROP ROWto remove duplicates - DSet the table property
delta.constraints.unique_idto 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
- Implement data cleaning by reading bronze tables with PySpark/SQL, cleaning nulls, standardizing data types, and writing to new silver tables.
- Combine DataFrames with operations such as Inner join, left join, broadcast join, multiple keys, cross join, union, and union all.
- Manipulate columns, rows, and table structures by adding, dropping, splitting, renaming column names, applying filters, and exploding arrays.
- Perform data deduplication operations and aggregate operations on DataFrames, such as count, approximate count distinct, and mean, summary.
- Understand the basic tuning parameters (spark.sql.shuffle.partitions, spark.default.parallelism, spark.executor/driver.memory, spark.sql.autoBroadcastJoinThreshold) and re-measure the performance.
- Understand the difference between, and how to build, Gold layer objects such as materialized views, views, streaming tables, and tables for BI and analytics teams in Unity Catalog.