A data engineer defines the following DLT pipeline table:
@dlt.table
@dlt.expect_or_fail("non_negative_amount", "amount >= 0")
def validated_transactions():
return dlt.read("raw_transactions")
During a pipeline run, 3 records arrive with amount = -5. What happens?
- A. The 3 records are written to the output table with a
_violated_expectationsmetadata column. - B. The 3 invalid records are quarantined into a separate DLT quarantine table.
- C. The pipeline completes successfully but logs the 3 violations as warnings in the DLT event log.
- D. The entire pipeline update fails immediately when the first invalid record is encountered.✓ Correct
- E. The 3 invalid records are silently dropped and the pipeline continues normally.
Explanation
expect_or_fail stops the update as soon as a record violates the constraint, so the pipeline fails and invalid data does not reach the target. A plain expect keeps the rows and records warnings, and expect_or_drop removes them and continues. No violation metadata column or quarantine table is created automatically. This code uses the legacy dlt module; current Lakeflow Spark Declarative Pipelines code uses from pyspark import pipelines as dp, with dp.table or dp.materialized_view and spark.read.table().