Data quality management is not something a single mechanism can solve. On Databricks, combining four layers — in-pipeline quality control (DLT Expectations), table-level constraints (Delta Constraints), statistical quality monitoring (Lakehouse Monitor), and threshold-based notifications (SQL Alerts) — lets you build an end-to-end quality strategy from detection through notification and remediation.
Each layer targets a different phase and detection timing. Moving from upstream to downstream through the pipeline, the design lays out defensive lines in the order prevent → detect → monitor → notify.
| Layer | Function | Target Phase | Detection Timing | Action |
|---|---|---|---|---|
| Layer 1 | DLT Expectations | During pipeline execution | Row level (per batch) | Choose warn / drop / fail |
| Layer 2 | Delta Constraints | On table write | Row level (INSERT/UPDATE) | Reject the transaction on constraint violation |
| Layer 3 | Lakehouse Monitor | After table updates (scheduled) | Column statistics and drift | Record to the metrics table |
| Layer 4 | SQL Alerts | Scheduled execution | Aggregate value exceeds threshold | Slack / Email / Webhook notification |
Delta Live Tables (DLT) Expectations is a mechanism for declaratively embedding quality rules inside the pipeline definition. For each Expectation you specify the behavior on violation (warn / drop / fail).
import dlt
from pyspark.sql.functions import col
@dlt.expect_or_drop("valid_amount", "amount > 0")
@dlt.expect_or_fail("not_null_user_id", "user_id IS NOT NULL")
@dlt.expect("valid_email", "email LIKE '%@%'")
@dlt.table(comment="Quality-validated order data")
def orders_clean():
return dlt.read("orders_raw").filter(col("order_date") >= "2025-01-01")Expectation results are recorded in the DLT pipeline's event log, and you can check the pass rate in the DAG view of the UI. It is well-suited for null removal and format validation during Bronze → Silver transformations and acts as a quality gate in the Medallion architecture.
Delta Constraints is a mechanism for setting NOT NULL and CHECK constraints on Delta tables. Even for batch jobs or SQL-based ETL that do not use DLT, you can stake out a last line of defense on the table itself.
-- Add NOT NULL constraints
ALTER TABLE gold.orders
ALTER COLUMN order_id SET NOT NULL;
ALTER TABLE gold.orders
ALTER COLUMN customer_id SET NOT NULL;
-- Add CHECK constraints
ALTER TABLE gold.orders
ADD CONSTRAINT valid_amount CHECK (amount > 0);
ALTER TABLE gold.orders
ADD CONSTRAINT valid_status CHECK (status IN ('pending', 'shipped', 'delivered', 'cancelled'));
-- Inspect the constraints
DESCRIBE DETAIL gold.orders;On a constraint violation, the entire INSERT/UPDATE/MERGE transaction is rolled back. The difference from DLT Expectations is that DLT is bound to a pipeline definition, whereas Delta Constraints are persisted on the table definition. The constraints apply no matter which ETL tool or job writes to the table, which makes them especially effective in multi-pipeline environments.
Lakehouse Monitor is a feature that periodically measures column statistics (null rate, mean, distribution) and data drift on Unity Catalog managed tables. It has two modes: snapshot analysis and time-series analysis.
-- Create a Lakehouse Monitor (SQL)
CREATE MONITOR gold.orders
WITH (
PROFILE_TYPE = 'SNAPSHOT',
SCHEDULE = CRON '0 8 * * *', -- Run every morning at 8:00
OUTPUT_SCHEMA = gold
);
-- Time-series mode
CREATE MONITOR gold.daily_metrics
WITH (
PROFILE_TYPE = 'TIME_SERIES',
TIMESTAMP_COL = 'event_date',
GRANULARITIES = ('1 day'),
SCHEDULE = CRON '0 9 * * *',
OUTPUT_SCHEMA = gold
);Monitor automatically generates two tables.
When applied to an ML model's input table, it lets you detect feature distribution shifts (data drift) early and provides input for the model retraining decision.
SQL Alerts is a mechanism that sends notifications when the result of a SQL query exceeds a threshold. You configure them against Lakehouse Monitor metrics tables or your own quality-check queries.
-- Example alert query: detect columns with > 5% null rate
SELECT
column_name,
ROUND(percent_nulls * 100, 2) AS null_pct
FROM gold.profile_metrics
WHERE log_date = CURRENT_DATE()
AND percent_nulls > 0.05
ORDER BY null_pct DESCRegister this query as a Databricks SQL Alert and configure it to notify a Slack channel when at least one result row exists. The evaluation interval can be set as fast as 1 minute.
Here is the typical flow in which the four layers work together.
[Raw Data]
│
v
[DLT Pipeline]
├─ Expectation: expect_or_drop("valid_amount", "amount > 0")
├─ Expectation: expect_or_fail("not_null_id", "id IS NOT NULL")
│ → Violating rows are quarantined / stop the run; metrics go to the event log
v
[Silver/Gold Table]
├─ Delta Constraint: CHECK (amount > 0), NOT NULL (id)
│ → Reject the transaction on constraint violation
v
[Lakehouse Monitor] (every morning at 8:00)
├─ profile_metrics: null rate, distribution, summary statistics
├─ drift_metrics: drift from the baseline
v
[SQL Alert] (fires when result rows > 0)
└─ Slack / Email / Webhook → ops team investigates| Axis | DLT Expectations | Delta Constraints | Lakehouse Monitor | SQL Alerts |
|---|---|---|---|---|
| When it applies | During pipeline execution | On write | Scheduled | Scheduled |
| Granularity | Row level | Row level | Column statistics | Aggregate value |
| Requires DLT? | Yes | No | No | No |
| Behavior on violation | warn/drop/fail | Reject the transaction | Record metrics | Fire a notification |
| Primary use case | Quality gate inside ETL | Last line of defense on the table | Drift detection and statistical monitoring | Operational notifications |
| Adoption cost | Limited to DLT pipelines | A single ALTER TABLE statement | CREATE MONITOR | GUI or SQL |
Data Engineer Associate / Professional
問題 1
A data engineer is running a Bronze → Silver transformation in a DLT pipeline. They want to drop rows where the amount column is negative, keep the pipeline running, and record the number of dropped rows as a metric. Which approach is most appropriate?
正解: A
expect_or_drop drops rows that violate the condition and keeps the pipeline running, while recording the number of dropped rows in the event log. expect_or_fail stops the entire pipeline on a violation, so it does not fit the requirement. Delta Constraints only reject the write and cannot selectively drop rows. Lakehouse Monitor performs after-the-fact statistical monitoring and cannot filter rows inside the pipeline.
Should I introduce DLT Expectations or Delta Constraints first?
When the data ingestion path is well-defined, introducing DLT Expectations first and controlling data quality inside the pipeline is the most effective approach. On the other hand, if you want to add guardrails to existing Delta tables after the fact, starting with Delta Constraints (CHECK / NOT NULL) lets you introduce them with minimal impact on existing pipelines. The two are not mutually exclusive: a layered defense that detects and quarantines quality violations in DLT while also setting constraints on the Delta table as a last line of defense is the recommended pattern.
Where are Lakehouse Monitor metrics stored?
Lakehouse Monitor automatically generates two Delta tables, profile_metrics and drift_metrics, inside the same schema as the monitored table. Because these tables are managed under Unity Catalog, you can query them with ordinary SQL. The retention period follows the table's own retention policy, and you can also reference past snapshots with Time Travel.
Besides Slack, what notification destinations can SQL Alerts use?
SQL Alerts supports email, Slack, and Webhooks (PagerDuty, Microsoft Teams, etc.) as notification destinations. Webhooks let you send notifications to any HTTP endpoint, which makes integration with ops management tools and incident management systems possible. The notification frequency depends on the alert's evaluation interval (as fast as 1 minute).
Practice with certification-focused question sets
無料で問題を解いてみるNicheeLab Editorial Team
NicheeLab editorial team focused on data engineering and cloud certification learning. Content is structured around practical study needs and official exam domains.
Databricks Certifications: All 7 Exams, Difficulty & Study Plan (2026)
Complete guide to all 7 Databricks certifications — Data Eng...
Databricks Exam Difficulty Ranking: All 7 Certs Compared (2026)
Every Databricks certification ranked by difficulty, with st...
Databricks Study Guide: Fastest Pass Route & Time Estimates (2026)
How to pass Databricks certifications efficiently. Official ...
Databricks Data Engineer Associate: Complete Guide (2026)
Domain-by-domain breakdown of the Databricks Certified Data ...
Databricks Data Engineer Professional: Complete Guide (2026)
Tactics for the Databricks Certified Data Engineer Professio...