Enforce data quality in a Lakeflow Declarative Pipeline (formerly Delta Live Tables) using expectations

domain: data-engineering · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Decorate a Python table/view function with @dp.expect("name", "constraint_sql") to log violations while still writing the rows — this is the default warn-and-keep behavior.
  2. Use @dp.expect_or_drop("name", "constraint_sql") to silently drop violating rows before they're written to the target table.
  3. Use @dp.expect_or_fail("name", "constraint_sql") to stop pipeline execution immediately on the first violation.
  4. For multiple constraints at once, use the grouped forms expect_all / expect_all_or_drop / expect_all_or_fail, passing a dict of {name: constraint}.
  5. In SQL pipelines, use CONSTRAINT <name> EXPECT (<expr>) ON VIOLATION {FAIL UPDATE | DROP ROW} inline on CREATE STREAMING TABLE / CREATE MATERIALIZED VIEW — omitting ON VIOLATION defaults to warn-and-keep.
  6. Check the pipeline event log's ExpectationMetrics for per-constraint pass/fail row counts rather than inferring quality from before/after row counts.

Known gotchas

Related routes

Enforce Delta Lake CHECK constraints and generated columns to guarantee data quality at write time
docs.delta.io · 5 steps · unrated
Enable and query Delta Lake Change Data Feed (CDF) for incremental downstream pipelines
delta.io · 5 steps · unrated
Validate pipeline data with Great Expectations
docs.greatexpectations.io · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans