pola-rs/polars · error
fill-null strategy is not supported
Error message
fill-null strategy {:?} is not supported What it means
fill_null for binary/string-backed ChunkedArrays only implements a subset of FillNullStrategy: Min, Max, Zero (and forward/backward handled elsewhere). Any other strategy (e.g. Mean, One, MinForward, specific value strategies not implemented for binary) is rejected via polars_bail with this InvalidOperation error.
Solutions
- Use a supported strategy for binary: Min, Max, or Zero (empty value)
- Fill with an explicit literal value: fill_null with value b"" / a chosen sentinel
- Strategize per dtype: apply mean only to numeric columns and a literal to binary/string columns
Example fix
// before let filled = ca.fill_null(FillNullStrategy::Mean)?; // not supported for binary // after let filled = ca.fill_null_with_values(b"")?; // or FillNullStrategy::Zero
Defensive patterns
Strategy: validation
Validate before calling
let supported = matches!(strat, FillNullStrategy::Min | FillNullStrategy::Max | FillNullStrategy::Zero | FillNullStrategy::Forward(_) | FillNullStrategy::Backward(_));
if series.dtype() == &DataType::Binary && !supported {
// use fill_null_with_values instead
} Try / catch
match ca.fill_null(strat) { Err(e) if e.to_string().contains("not supported") => ca.fill_null_with_values(b""), r => r } Prevention
- Only apply numeric strategies (Mean, One) to numeric columns
- Per-dtype strategy maps in generic DataFrame-wide fill-null code
- Use explicit fill values for binary/string columns
When it happens
Trigger: Calling Series/Expr fill_null with strategy = Mean/One/etc. on a column of dtype Binary (or Utf8 backed binary path) where the strategy has no binary implementation.
Common situations: Reusing a fill_null strategy that works on numeric columns (mean) on a binary/string column; generic fill-null code that applies the same strategy to all columns of a DataFrame.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- {0}
- activate dtype
- activate dtype-categorical to convert dictionary arrays
- activate ' ' feature
- activate feature dtype-date
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/4244e452f1928b3e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-core/src/chunked_array/ops/fill_null.rs:402
FillNullStrategy::Mean => polars_bail!(opq = mean, "Boolean"),
FillNullStrategy::One => ca.fill_null_with_values(true).map(|ca| ca.into_series()),
FillNullStrategy::Zero => ca.fill_null_with_values(false).map(|ca| ca.into_series()),
FillNullStrategy::Forward(_) => unreachable!(),
FillNullStrategy::Backward(_) => unreachable!(),
}
}
fn fill_null_binary(ca: &BinaryChunked, strategy: FillNullStrategy) -> PolarsResult<BinaryChunked> {
match strategy {
FillNullStrategy::Min => {
ca.fill_null_with_values(ca.min_binary().ok_or_else(err_fill_null)?)
},
FillNullStrategy::Max => {
ca.fill_null_with_values(ca.max_binary().ok_or_else(err_fill_null)?)
},
FillNullStrategy::Zero => ca.fill_null_with_values(&[]),
FillNullStrategy::Forward(_) => unreachable!(),
FillNullStrategy::Backward(_) => unreachable!(),
strat => polars_bail!(InvalidOperation: "fill-null strategy {:?} is not supported", strat),
}
}
impl<T> ChunkFillNullValue<T::Native> for ChunkedArray<T>
where
T: PolarsNumericType,
{
fn fill_null_with_values(&self, value: T::Native) -> PolarsResult<Self> {
Ok(self.apply_kernel(&|arr| Box::new(set_at_nulls(arr, value))))
}
}
impl ChunkFillNullValue<bool> for BooleanChunked {
fn fill_null_with_values(&self, value: bool) -> PolarsResult<Self> {
self.set(&self.is_null(), Some(value))
}
}View on GitHub (pinned to fe841f959e)