ilir_nuredini
Honored Contributor

Hello mai_luca

The expectation in your @Dlt.expect_or_fail() is only evaluated if the view is used downstream by a materialized table. If the view is only referenced by another view, or not used at all, the expectation will not be evaluated. DLT will not materialize the view, and the check will be skipped entirely.

Behind the scenes, here's what happens:

1. Views in DLT are logical constructs. They are not stored in the metastore or physically persisted.

2. DLT evaluates views lazily. This means a view is only computed if it is referenced by something downstream, such as a table.

3. If an expectation is attached to a view, it is only applied when that view is actually evaluated.

So, if no downstream @Dlt.table consumes 'view_name', the expectation will not run, and the pipeline will not fail, even if the data violates the condition.


Best,
Ilir

View solution in original post