pola-rs/polars · error

not implemented

Error message

not implemented

What it means

polars-compute implements TotalOrdKernel (total-order comparisons backing <, <= and ordering-sensitive ops) for most arrays, but NullArray - the Arrow array behind polars' Null dtype (an all-null column) - has unimplemented!() stubs. tot_lt_kernel panics with 'not implemented' as soon as it is called. Equality kernels on NullArray are implemented; ordering deliberately is not.

Source

Thrown at crates/polars-compute/src/comparisons/null.rs:40

    fn tot_ne_kernel_broadcast(&self, _other: &Self::Scalar) -> Bitmap {
        todo!()
    }
}

impl TotalOrdKernel for NullArray {
    type Scalar = Box<dyn Array>;

    fn tot_lt_kernel(&self, _other: &Self) -> Bitmap {
        unimplemented!()
    }

    fn tot_le_kernel(&self, _other: &Self) -> Bitmap {
        unimplemented!()
    }

    fn tot_lt_kernel_broadcast(&self, _other: &Self::Scalar) -> Bitmap {
        unimplemented!()
    }

    fn tot_le_kernel_broadcast(&self, _other: &Self::Scalar) -> Bitmap {
        unimplemented!()
    }

    fn tot_gt_kernel_broadcast(&self, _other: &Self::Scalar) -> Bitmap {
        unimplemented!()
    }

    fn tot_ge_kernel_broadcast(&self, _other: &Self::Scalar) -> Bitmap {
        unimplemented!()
    }
}

View on GitHub (pinned to 9b5d73fd00)

Solutions

  1. Cast the Null column to a concrete dtype before ordering: pl.col("n").cast(pl.String) or the dtype the column should have had
  2. Replace ordering predicates on Null columns with null-aware logic: pl.col("n").is_null() / is_not_null(), which never enters the ordering kernel
  3. Drop all-Null columns early: df.drop([c for c, t in df.schema.items() if t == pl.Null])

Example fix

# before
df.filter(pl.col("empty") < pl.col("empty2"))  # both dtype pl.Null -> unimplemented
# after
df.filter(pl.col("empty").cast(pl.Int64) < pl.col("empty2").cast(pl.Int64))
Defensive patterns

Strategy: type-guard

Validate before calling

# before ordering/filtering generically over columns
null_cols = [c for c, t in df.schema.items() if t == pl.Null]
if null_cols:
    df = df.with_columns([pl.col(c).cast(pl.String) for c in null_cols])

Type guard

# Python
def is_null_dtype(s: pl.Series) -> bool:
    return s.dtype == pl.Null

Prevention

When it happens

Trigger: An inequality comparison on a Null-dtype column: pl.col("n") < pl.col("n2") or Series.lt/lt_eq where an operand has dtype pl.Null, range predicates such as is_between that lower to gt_lt/tot_lt kernels with Null operands, and any direct Rust call to tot_lt_kernel on a NullArray.

Common situations: All-null columns arise easily: empty join results, pl.lit(None) typed as Null, CSV/JSON columns where every value is missing, or generic code that processes arbitrary schemas. Sorting or range-filtering such a column - often a rarely exercised branch - then panics.

Related errors


AI-assisted analysis of pola-rs/polars@9b5d73fd00 (2026-08-19). Data as JSON: /api/errors/f5d25b530e3defa8. Report an issue: GitHub.