Skip to content

Assert not null: assertNotNull

Verify that one or more columns contain no null (missing) values.

Floating-point NaN values also count as missing, both in the application and in exported pandas or Polars code. A row with multiple missing fields counts as one violation. The text "NaN" in a string column is not a missing value.

The node is pass-through: the dataframe leaves unchanged regardless of the outcome. The violation is recorded in the run's per-node result and either fails the run (error mode) or logs a warning and continues (warn mode).

Use cases

  • Enforce that a primary-key column is never null before a join.
  • Validate that required fields (email, user_id) are populated after an ingestion step.
  • Add a contract at the boundary between two teams' pipelines without changing the data shape.

Configuration

Config keyTypeRequiredDescription
columnslist of stringsNoColumns that must be non-null. Empty (or omitted) checks every column.
mode"error" | "warn"No"error" (default) stops the run; "warn" continues and logs

Behavior

OutcomeWhat happens
All specified columns are non-nullRun continues; assertion_passed: true
Any null found, mode: "error"Run fails; error message names the column and null count
Any null found, mode: "warn"Run continues; warning recorded with column and null count

The per-node result in the run detail always includes assertion_passed, assertion_violation_count, and a sample of up to 5 violating rows.

Generated Python code

pandas

python
_null_mask = df_1[['user_id', 'email']].isnull().any(axis=1)
if _null_mask.any():
    raise ValueError(f"assertNotNull: {_null_mask.sum()} row(s) contain nulls in ['user_id', 'email']")

Polars

python
df_1 = df_1
_null_checks = [
    pl.col(_col).is_null() | pl.col(_col).is_nan()
    if df_1.schema[_col].is_float() else pl.col(_col).is_null()
    for _col in ['user_id', 'email']
]
_null_count = df_1.select(pl.any_horizontal(_null_checks)).to_series().sum()
if _null_count > 0:
    raise ValueError(f"assertNotNull: {_null_count} row(s) contain nulls in ['user_id', 'email']")

In warn mode the raise is replaced by a warnings.warn(...) call and execution continues.

Tips & common mistakes

  • The dataframe is unchanged. Place this node anywhere in the graph where you want a contract check, then continue with other nodes after it.
  • Use warn during development. Switch to error when the pipeline goes into production to catch real data issues early.
  • Use Drop nulls if you want to remove null rows instead of asserting they don't exist.

See also