pola-rs/polars · error
invalid value for POLARS_ROW_GROUP_PREFETCH_SIZE
Error message
invalid value for POLARS_ROW_GROUP_PREFETCH_SIZE: {x} What it means
Polars panics when POLARS_ROW_GROUP_PREFETCH_SIZE is set but not parseable as a non-zero usize. This variable bounds how many Parquet row groups may be in flight (prefetched) at once during a streaming Parquet scan. Parsing runs in set_execution_state; any invalid value aborts the query immediately.
Solutions
- Unset POLARS_ROW_GROUP_PREFETCH_SIZE to use the pipeline-derived default
- Set it to a plain positive decimal integer, e.g. export POLARS_ROW_GROUP_PREFETCH_SIZE=32
- Validate the value is >= 1 and fits a usize before exporting it
Example fix
// before export POLARS_ROW_GROUP_PREFETCH_SIZE=16.0 // after export POLARS_ROW_GROUP_PREFETCH_SIZE=16
Defensive patterns
Strategy: validation
Validate before calling
// Rust: validate before running the scan
if let Ok(v) = std::env::var("POLARS_ROW_GROUP_PREFETCH_SIZE") {
assert!(v.parse::<NonZeroUsize>().is_ok(), "POLARS_ROW_GROUP_PREFETCH_SIZE must be a positive integer, got: {v}");
} Type guard
fn valid_prefetch_size(v: &str) -> bool { v.parse::<NonZeroUsize>().is_ok() } Prevention
- Use plain decimal integers for this variable (no floats, units, or quotes)
- Keep the value >= 1; there is no '0 = auto' semantics
- Document required env vars in job manifests to catch typos early
When it happens
Trigger: Setting POLARS_ROW_GROUP_PREFETCH_SIZE to a non-integer ('10.5'), zero, a negative number, a value with units, or a value exceeding usize::MAX, then running a Parquet scan via the streaming engine.
Common situations: Tuning guides with float or '64 rows' style values pasted into the env var; dotenv files adding quotes; users setting 0 intending 'auto'; typos like 'O64'.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- integer
- invalid value for POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET
- Invalid `POLARS_PQ_PREFILTERED_MASK` value
- invalid value for POLARS_MEMORY_PREFETCH
- invalid value for POLARS_NDJSON_CHUNK_SIZE
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/c4b750d7c318fb57.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-stream/src/nodes/io_sources/parquet/builder.rs:76
if matches!(
self.options.parallel,
ParallelStrategy::Auto | ParallelStrategy::Prefiltered
) {
capabilities |= RC::FULL_FILTER;
}
capabilities
}
fn set_execution_state(&self, execution_state: &crate::execute::StreamingExecutionState) {
// Bound the number of fetches in the pipeline.
// This bound goes together with the `prefetch_kbytes_limit` bound. In most
// large-dataset use cases, the kbytes memory bound will kick in first.
// This limit should be at least as large as the max in-flight concurrency.
let prefetch_limit = std::env::var("POLARS_ROW_GROUP_PREFETCH_SIZE")
.map(|x| {
x.parse::<NonZeroUsize>()
.unwrap_or_else(|_| {
panic!("invalid value for POLARS_ROW_GROUP_PREFETCH_SIZE: {x}")
})
.get()
})
.unwrap_or(
execution_state
.num_pipelines
.saturating_mul(2)
.max(get_request_budget() as usize)
.clamp(16, 2048),
)
.max(1);
// Bound the max memory in use for the pipeline.
// This should be large enough to be non-blocking, but small enough to avoid
// excessive memory use from a run-away prefetch pipeline.
// "Correct" formula: (a) max effective in-flight bdp-based bytes budget + (b) decode pipeline.
// Since we do not know (a) at startup, we use '3 * (b) + buffer' as a proxy for (a), where the
// multiplier reflects the max gain factor for in-flight control.View on GitHub (pinned to fe841f959e)