QuestionQ216

VerifiedData Transformation, Cleansing, and Quality

A data engineer is designing a Lakeflow Spark Declarative Pipeline for processing streaming order data. The pipeline uses Auto Loader for ingestion and must enforce data quality by ensuring that customer_id and amount are greater than zero. Invalid records must be dropped.

Which Python Lakeflow Spark Declarative Pipelines configuration implements these requirements?

Explanation

@dlt.expect_or_drop attaches a SQL data-quality expectation to the pipeline table and discards any record that fails the condition before it is written. Applying one expectation for the customer identifier and another for a positive amount therefore enforces the validations while dropping invalid rows. The non-dropping expectation form only reports violations, and expectations are declared as pipeline decorators rather than DataFrame methods.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!