pola-rs/polars · error

POLARS_NO_FAST_FILE_COUNT must be one of ('0', '1'), got

Error message

POLARS_NO_FAST_FILE_COUNT must be one of ('0', '1'), got: {v}

What it means

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`.

Solutions

  1. Set POLARS_NO_FAST_FILE_COUNT=1 to disable fast file count, or =0 / unset to keep default
  2. Replace 'true'/'false' style values with 1/0
  3. Audit shell profiles and deployment manifests for the stale value

Example fix

# before
POLARS_NO_FAST_FILE_COUNT=true
# after
POLARS_NO_FAST_FILE_COUNT=1
Defensive patterns

Strategy: validation

Validate before calling

import os
v = os.environ.get("POLARS_NO_FAST_FILE_COUNT")
assert v in (None, "0", "1"), f"POLARS_NO_FAST_FILE_COUNT must be '0' or '1', got {v!r}"

Type guard

def is_valid_flag(v: str | None) -> bool:
    return v in (None, "0", "1")

Prevention

When it happens

Trigger: 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.

Common situations: Using boolean-style 'true'/'false' in env config, or a leftover debug setting with a typo.

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


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/6712e0bb48b6a6c8. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-plan/src/plans/optimizer/projection_pushdown/mod.rs:1651

                // New-streaming is generally on par for all except CSV (see https://github.com/pola-rs/polars/pull/22363).
                // In the future we can potentially remove the dedicated count codepaths.
                #[cfg(feature = "csv")]
                if out_edge.projection() == Projection::Len
                    && let FileScanIR::Csv { .. } = scan_type.as_ref()
                    && unified_scan_args.pre_slice.is_none()
                    && (predicate.is_none()
                        || matches!(
                            predicate_file_skip_applied,
                            Some(PredicateFileSkip {
                                no_residual_predicate: true,
                                ..
                            })
                        ))
                    && (match std::env::var("POLARS_NO_FAST_FILE_COUNT").as_deref() {
                        Ok("0") | Err(_) => true,
                        Ok("1") => false,
                        Ok(v) => {
                            panic!("POLARS_NO_FAST_FILE_COUNT must be one of ('0', '1'), got: {v}")
                        },
                    })
                    && let Some(name) = extract_select_len_expr(parent_ir, self.expr_arena)
                        .map(|e| e.output_name().clone())
                {
                    // Replace the scan with empty DF scan as input to the MapFunction.
                    let dummy_ir = IR::DataFrameScan {
                        df: Arc::new(Default::default()),
                        schema: Arc::new(Default::default()),
                        output_schema: None,
                    };

                    let IR::Scan {
                        sources,
                        scan_type,
                        unified_scan_args,
                        ..
                    } = storage.replace(key, dummy_ir)

View on GitHub (pinned to fe841f959e)