High severitydata quality
Power BI Refresh Error:
NOT_NULL_CONSTRAINT_VIOLATION
What does this error mean?
A write operation attempted to insert NULL values into a column defined as NOT NULL. Delta Lake enforces this constraint at write time and rejects the entire batch to protect data integrity.
Common causes
- 1An upstream transformation produced NULL values in a column that was not expected to be nullable
- 2A JOIN expanded the dataset with unmatched rows, introducing NULLs in the key columns
- 3A new NOT NULL constraint was added to an existing column but existing pipelines still write nullable data
- 4A data source schema change caused a previously populated column to become absent or NULL
- 5A DEFAULT value was not specified for a new NOT NULL column when inserting partial rows
How to fix it
- 1Identify which column is violating the constraint: the error message includes the column path.
- 2Add a NULL filter upstream: WHERE col IS NOT NULL, or use COALESCE(col, default_value).
- 3Review the JOIN type — switch from LEFT JOIN to INNER JOIN if NULLs from unmatched rows are unacceptable.
- 4If the constraint is too strict, use ALTER TABLE DROP CONSTRAINT to remove it and add a CHECK constraint instead.
- 5Add a data quality expectation in Delta Live Tables: CONSTRAINT not_null EXPECT (col IS NOT NULL) ON VIOLATION DROP ROW.