{"record":{"id":"6712e0bb48b6a6c8","repo":"pola-rs/polars","slug":"polars-no-fast-file-count-must-be-one-of-0-1","errorCode":null,"errorMessage":"POLARS_NO_FAST_FILE_COUNT must be one of ('0', '1'), got: {v}","messagePattern":"POLARS_NO_FAST_FILE_COUNT must be one of \\('0', '1'\\), got: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-plan/src/plans/optimizer/projection_pushdown/mod.rs","lineNumber":1651,"sourceCode":"                // New-streaming is generally on par for all except CSV (see https://github.com/pola-rs/polars/pull/22363).\n                // In the future we can potentially remove the dedicated count codepaths.\n                #[cfg(feature = \"csv\")]\n                if out_edge.projection() == Projection::Len\n                    && let FileScanIR::Csv { .. } = scan_type.as_ref()\n                    && unified_scan_args.pre_slice.is_none()\n                    && (predicate.is_none()\n                        || matches!(\n                            predicate_file_skip_applied,\n                            Some(PredicateFileSkip {\n                                no_residual_predicate: true,\n                                ..\n                            })\n                        ))\n                    && (match std::env::var(\"POLARS_NO_FAST_FILE_COUNT\").as_deref() {\n                        Ok(\"0\") | Err(_) => true,\n                        Ok(\"1\") => false,\n                        Ok(v) => {\n                            panic!(\"POLARS_NO_FAST_FILE_COUNT must be one of ('0', '1'), got: {v}\")\n                        },\n                    })\n                    && let Some(name) = extract_select_len_expr(parent_ir, self.expr_arena)\n                        .map(|e| e.output_name().clone())\n                {\n                    // Replace the scan with empty DF scan as input to the MapFunction.\n                    let dummy_ir = IR::DataFrameScan {\n                        df: Arc::new(Default::default()),\n                        schema: Arc::new(Default::default()),\n                        output_schema: None,\n                    };\n\n                    let IR::Scan {\n                        sources,\n                        scan_type,\n                        unified_scan_args,\n                        ..\n                    } = storage.replace(key, dummy_ir)","sourceCodeStart":1633,"sourceCodeEnd":1669,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-plan/src/plans/optimizer/projection_pushdown/mod.rs#L1633-L1669","documentation":"During projection pushdown optimization, Polars checks POLARS_NO_FAST_FILE_COUNT, an opt-out flag for the fast file-count optimization (replacing a scan with an empty scan for count queries). Only '0' (enabled, default) or '1' (disabled) are accepted; any other value panics inside `pushdown`.","triggerScenarios":"Setting POLARS_NO_FAST_FILE_COUNT to any value other than '0' or '1' (e.g. \"true\", \"yes\", \"2\") and running a lazy query that optimizes a count over a file scan.","commonSituations":"Using boolean-style 'true'/'false' in env config, or a leftover debug setting with a typo.","solutions":["Set POLARS_NO_FAST_FILE_COUNT=1 to disable fast file count, or =0 / unset to keep default","Replace 'true'/'false' style values with 1/0","Audit shell profiles and deployment manifests for the stale value"],"exampleFix":"# before\nPOLARS_NO_FAST_FILE_COUNT=true\n# after\nPOLARS_NO_FAST_FILE_COUNT=1","handlingStrategy":"validation","validationCode":"import os\nv = os.environ.get(\"POLARS_NO_FAST_FILE_COUNT\")\nassert v in (None, \"0\", \"1\"), f\"POLARS_NO_FAST_FILE_COUNT must be '0' or '1', got {v!r}\"","typeGuard":"def is_valid_flag(v: str | None) -> bool:\n    return v in (None, \"0\", \"1\")","tryCatchPattern":null,"preventionTips":["Treat this flag strictly as 0/1, never true/false","Centralize polars env-var setup in one validated module","Audit CI/production env files for stray values"],"tags":["env-var","configuration","optimizer","panic"],"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"}