{"record":{"id":"c4b750d7c318fb57","repo":"pola-rs/polars","slug":"invalid-value-for-polars-row-group-prefetch-size","errorCode":null,"errorMessage":"invalid value for POLARS_ROW_GROUP_PREFETCH_SIZE: {x}","messagePattern":"invalid value for POLARS_ROW_GROUP_PREFETCH_SIZE: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-stream/src/nodes/io_sources/parquet/builder.rs","lineNumber":76,"sourceCode":"        if matches!(\n            self.options.parallel,\n            ParallelStrategy::Auto | ParallelStrategy::Prefiltered\n        ) {\n            capabilities |= RC::FULL_FILTER;\n        }\n        capabilities\n    }\n\n    fn set_execution_state(&self, execution_state: &crate::execute::StreamingExecutionState) {\n        // Bound the number of fetches in the pipeline.\n        // This bound goes together with the `prefetch_kbytes_limit` bound. In most\n        // large-dataset use cases, the kbytes memory bound will kick in first.\n        // This limit should be at least as large as the max in-flight concurrency.\n        let prefetch_limit = std::env::var(\"POLARS_ROW_GROUP_PREFETCH_SIZE\")\n            .map(|x| {\n                x.parse::<NonZeroUsize>()\n                    .unwrap_or_else(|_| {\n                        panic!(\"invalid value for POLARS_ROW_GROUP_PREFETCH_SIZE: {x}\")\n                    })\n                    .get()\n            })\n            .unwrap_or(\n                execution_state\n                    .num_pipelines\n                    .saturating_mul(2)\n                    .max(get_request_budget() as usize)\n                    .clamp(16, 2048),\n            )\n            .max(1);\n\n        // Bound the max memory in use for the pipeline.\n        // This should be large enough to be non-blocking, but small enough to avoid\n        // excessive memory use from a run-away prefetch pipeline.\n        // \"Correct\" formula: (a) max effective in-flight bdp-based bytes budget + (b) decode pipeline.\n        // Since we do not know (a) at startup, we use  '3 * (b) + buffer' as a proxy for (a), where the\n        // multiplier reflects the max gain factor for in-flight control.","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-stream/src/nodes/io_sources/parquet/builder.rs#L58-L94","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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"],"exampleFix":"// before\nexport POLARS_ROW_GROUP_PREFETCH_SIZE=16.0\n// after\nexport POLARS_ROW_GROUP_PREFETCH_SIZE=16","handlingStrategy":"validation","validationCode":"// Rust: validate before running the scan\nif let Ok(v) = std::env::var(\"POLARS_ROW_GROUP_PREFETCH_SIZE\") {\n    assert!(v.parse::<NonZeroUsize>().is_ok(), \"POLARS_ROW_GROUP_PREFETCH_SIZE must be a positive integer, got: {v}\");\n}","typeGuard":"fn valid_prefetch_size(v: &str) -> bool { v.parse::<NonZeroUsize>().is_ok() }","tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","environment-variable","configuration","parquet"],"backgroundTag":"invalid-env-var-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}