Picture a driver-app release that starts sending driver profiles with no driver_id. (The business here is RideFlow, a fictional ride-hailing company.) The pipeline accepts them. A downstream report now holds records it cannot reliably identify, and the team has to trace every table the rows reached.
It happens when a pipeline loads first and checks later, which is a common pattern. The check that would have caught the missing keys runs after the data is published, or nowhere, because the rule lives in someone's head.
The short answer: check each row as it enters the first cleaned layer, keep failing rows aside with the reason attached, and record whether the batch as a whole met its limits. This post covers the ways teams do that today, where each fits, and how LakeLogic handles it. It does not argue that monitoring is unnecessary; inline checks and monitoring answer different questions.
Two questions, two kinds of check
An inline gate answers two separate questions:
- Is this row valid? A required key is present, an amount is not negative, a status uses an accepted value. A row rule looks at one record.
- Is this batch fit to use? Keys are unique, the row count is within its usual range, the share of rejected rows is acceptable. A dataset check looks at the whole batch.
They fail differently. One bad row in a million is usually best set aside so the rest can flow. A batch where every row is individually valid but half of yesterday's volume is missing passes every row rule and is still wrong.
source rows
|
row rules ----+-- valid rows ------> Silver table
+-- failed rows -----> quarantine table (with the failing rule)
|
dataset checks --> unique keys, row counts, rejected share
|
pass: recorded breach: recorded and alerted
Why bad rows travel
- Validation sits at the end. Tests and monitors that read the published table are valuable, but by the time they run, downstream jobs may already have read it.
- Rejecting is all or nothing. Many frameworks offer "fail the job" or "keep everything". Failing on one bad row trains teams to switch the check off; keeping everything lets the bad row through.
- Dropped rows leave no trail. A filter that silently removes bad records hides the problem from the producer, who is the only person who can fix it.
The ways teams solve it
These all work, and many teams combine two of them.
| Approach | How it works | Good fit | Watch out for |
|---|---|---|---|
| Databricks pipeline expectations | Per-constraint action: warn, drop the row, or fail the update | Lakeflow declarative pipelines | Dropped rows are counted, not kept |
| dbt model contracts and data tests | Contracts check names and types at build; tests query the model afterwards | dbt, SQL-first teams | Enforced constraints vary by platform; tests see data already written |
| Great Expectations | A Checkpoint validates suites and runs actions on the results | Python pipelines, rich validation | Routing failed rows is your code |
| Soda | YAML checks run as a scan; can stop the calling job | Dataset checks across warehouses | Failed-row samples, not a quarantine path |
| Hand-written split | A WHERE clause sends good and bad rows to different tables | One or two critical tables | Rules can drift; failure reasons are extra work |
Two details matter in practice. Databricks expectations count dropped rows in pipeline metrics; keeping them for review needs the separate quarantine pattern its docs describe. Hand-written splits work well while the rules live in one place; once the same rule is copied into several pipelines, the copies tend to drift.
What these leave open is the join between the two questions: one definition of the rules that both splits the rows and keeps the reason, and also judges the batch, without a second copy of the rules in orchestration code. That is the gap LakeLogic is designed around.
How LakeLogic approaches it
A LakeLogic contract declares the table's row rules and dataset rules. The runtime evaluates them while it processes the data, on Spark, Polars, DuckDB and the other supported engines.
Row rules split the data. Each rule is a SQL condition. Rows that pass go to the target table; rows that fail go to a quarantine target with an _lakelogic_errors column listing every rule they failed. On Spark the entry reads [pre] Rule failed: <rule> (<sql>), where pre or post says whether the check ran before or after the contract's transformations. A _lakelogic_categories column carries each rule's category, such as completeness or validity.
Here are some of the rules on a Silver driver profiles table in the reference project:
# contracts/marketplace/rideflow/contracts/silver/silver_rideflow_driver_profiles.yaml (excerpt)
quality:
row_rules:
- name: driver_id_not_null
sql: driver_id IS NOT NULL
category: completeness
- name: rating_range_max
sql: rating IS NULL OR rating <= 5
category: validity
- name: status_accepted_values
sql: status IS NULL OR status IN ('active', 'deleted', 'inactive', 'pending', 'suspended')
category: validity
![Databricks Catalog Explorer showing the quarantine table for driver profiles: each row's _lakelogic_errors reads "[pre] Rule failed: driver_id_not_null", with category "completeness" and the source table](/blog/rideflow/databricks_quarantine_table.png)
RideFlow reference project, a fictional ride-hailing business with synthetic data. The quarantine table for Silver driver profiles in Databricks, filtered on _lakelogic_errors. Each rejected row says which rule it failed and where it came from.
Dataset rules check the batch. Uniqueness, null ratios and row-count ranges are declared once and recorded as passed or failed on the run, with the measured value. A gold dimension in the same project declares its key this way:
quality:
dataset_rules:
- unique:
columns: [Id, effective_from]
name: Id_effective_from_unique
Thresholds say how much rejection is acceptable. A domain can set a quality objective on the share of good and quarantined rows:
# contracts/marketplace/_domain.yaml (excerpt)
slo:
quality:
min_good_ratio: 0.92
max_quarantine_ratio: 0.08
After a run, LakeLogic compares each table's counts with these limits and records a pass or a breach, which can raise an alert through the configured notifications. A table that kept no rows at all is a breach when an objective is set.
A breach and a rejected row are handled differently.
-
A quality threshold is breached: LakeLogic records the breach and alerts. It does not stop the run.
-
A dataset rule fails (for example, duplicate keys): recorded and alerted by default. With
quality.fail_pipeline_on_dataset_error: true, the run stops instead. -
Any row is rejected: optionally, fail the run. With
quarantine.fail_on_quarantine: true, the run fails as soon as a table quarantines any row, whatever the threshold, and the error lists up to ten of the failing rules. Valid rows have already been written by then; what the failure stops is the rest of the run. -
Without it, a table that quarantines every row is reported as
all_rows_quarantined, and one that rejects more rows than it keeps asmostly_quarantined, never as a plain success.
If a threshold breach must stop downstream jobs, make them depend on a job that fails on the breach. Projects generated by Lakehouse Studio include one: RideFlow's pl_monitor_slo evaluates the objectives and fails on a breach by default (fail_on_breach: true). Or use fail_on_quarantine on the tables where any bad row is unacceptable.
Thresholds should follow business risk. A marketing events feed can tolerate a few rejected events; RideFlow's Payments domain sets min_good_ratio: 0.99, stricter than Marketplace.
When you might not need this
- Your transformations already run in Databricks declarative pipelines and dropping bad rows with a logged count is acceptable. Expectations do that natively.
- Everything is dbt and post-build tests that fail the run before anyone queries the table are enough for your consumers.
- One or two critical tables. A hand-written good/bad split with a reason column is easy to maintain at that size.
LakeLogic earns its place when many tables, owned by different teams, need the same rules to split rows, explain failures and judge batches, defined in one place.
Limits worth knowing
- Inline checks cost compute. Row rules add work to every run, and dataset rules add queries. Keep cheap deterministic rules inline and run expensive checks only on high-risk products. Measure check time beside pipeline time.
- A passing rule only proves what it checks. A batch can satisfy every declared rule and still be wrong in ways nobody wrote down.
- Quarantine is a queue, not a fix. Someone has to own it: repair the source, correct the rule, replay the rows or record an exception. An unread quarantine table is another data swamp.
- Monitoring still matters. Inline gates protect the current run. Trends across runs (growing quarantine, one source breaking repeatedly, freshness slipping) need monitoring over the run history.
Key takeaways
- Separate the two questions: row rules decide what happens to a record, dataset checks decide whether a batch is fit to use.
- Keep failed rows, with the failing rule on each, so the producer can see and fix the cause.
- Choose between quarantine and stopping the run per table, by the business cost of bad data.
- Know which checks halt a run and which only record and alert; do not assume a threshold blocks downstream jobs.
- Pair inline checks with monitoring; one protects this run, the other improves the next hundred.
To follow one bad record from source to quarantine across several domains, read Who Owns a Negative Fare? A Governed Data Mesh on Databricks.
Try it
Run the Data Quality and Trust notebook in Google Colab. It feeds clean and dirty records through a contract and shows the quarantined rows with their error reasons.