Medium severityexecution
Power BI Refresh Error:
NULL_VALUE_IN_NON_NULLABLE_COLUMN
What does this error mean?
A NULL value was inserted or loaded into a column defined with a NOT NULL constraint. Snowflake enforces NOT NULL at write time and rejects the row.
Common causes
- 1Source data contains missing values for a required field
- 2A JOIN or transformation produces NULL for a column that was non-nullable in a previous step
- 3COPY INTO file has missing columns or empty fields that map to NOT NULL columns
- 4A DEFAULT value was not set on the NOT NULL column, so absent values produce NULL
- 5An ETL tool generating INSERT statements omits columns that have NOT NULL constraints
How to fix it
- 1Identify the column: the error message includes the column name and offending value
- 2Add a COALESCE in the INSERT/transformation to provide a fallback: COALESCE(source_col, 'unknown')
- 3If NULLs are acceptable, alter the column to remove the NOT NULL constraint: ALTER TABLE my_table ALTER COLUMN my_col DROP NOT NULL
- 4Set a column DEFAULT: ALTER TABLE my_table ALTER COLUMN my_col SET DEFAULT 'N/A'
- 5For COPY INTO, use the NULL_IF option to convert empty strings to a non-null sentinel: NULL_IF = ('')