pola-rs/polars · error

predicate not boolean

Error message

predicate not boolean

What it means

Generic polars error raised in apply_extra_ops when evaluating a scan predicate yields a non-boolean mask: multi_scan requires filter predicates to resolve to Boolean so it can use the mask for row selection; any other dtype at this point is a predicate/plan bug rather than bad user input.

Source

Thrown at crates/polars-stream/src/nodes/io_sources/multi_scan/components/apply_extra_ops.rs:336

                }),
            );

            let offset = ri.offset.saturating_add(
                current_row_position
                    .add(local_offset_adjustment)
                    .num_rows_idxsize_saturating()?,
            );

            let row_index_col = Column::new_row_index(ri.name.clone(), offset, df.height())?;

            debug_assert_eq!(df.columns()[*col_idx].name(), &ri.name);

            unsafe { *df.columns_mut().get_mut(*col_idx).unwrap() = row_index_col }
        }

        if let Some(predicate) = predicate {
            let mask = predicate.predicate.evaluate_io(df)?;
            *df = df.filter_seq(mask.bool().expect("predicate not boolean"))?;
        }

        Ok(())
    }
}

View on GitHub (pinned to 9b5d73fd00)

Solutions

  1. Ensure the predicate/filter expression returns a boolean column; cast or rewrite the expression to produce booleans.

Example fix

lf = lf.filter(pl.col('a') > 0)  # boolean predicate
Defensive patterns

Strategy: validation

When it happens

Trigger: A scan predicate expression evaluated to a non-boolean dtype.

Common situations: See trigger scenarios.


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