pola-rs/polars · error · ComputeError

statistics load failure for filter column

Error message

statistics load failure for filter column: {p}

What it means

While building column statistics for an Iceberg scan, identity-transformed values for a filter column are looked up by field ID. If the value is a string, it is treated as an error condition and a polars ComputeError('statistics load failure for filter column: ...') is raised — the statistics payload for that column is not usable as a filter value.

Solutions

  1. Inspect the table's partition/stats metadata (pyiceberg) for the offending field and fix or regenerate statistics
  2. Bypass statistics-based pruning if possible (e.g. disable the relevant filter or re-write table metadata)
  3. Re-write the table with a current pyiceberg version so stats conform to expectations
  4. Report/upgrade — if polars misinterprets valid stats, this may be a polars bug to file

Example fix

// before
lf = pl.scan_iceberg(table, filter=bad_filter)  # ComputeError at stats finish
// after
# drop the unsupported filter column or fix table stats first
lf = pl.scan_iceberg(table).filter(pl.col('col'))
Defensive patterns

Strategy: try-catch

Validate before calling

# inspect identity partition fields before scanning
for field in table.metadata.partition_fields():
    print(field.field_id, field.transform)  # confirm identity transforms/stats look sane

Try / catch

try:
    df = pl.scan_iceberg(table).collect()
except pl.exceptions.ComputeError as e:
    if 'statistics load failure' in str(e):
        df = pl.from_arrow(table.scan().to_arrow())  # bypass stats path

Prevention

When it happens

Trigger: Scanning an Iceberg table whose file/column statistics metadata contains a string where a non-string (e.g. numeric/datetime) transformed value is expected for an identity-partitioned filter column, in `FileStatisticsBuilder.finish` during scan_iceberg.

Common situations: Corrupt or unexpected stats written by another writer; identity partition fields whose transformed value serialized as a string; version mismatches between pyiceberg metadata writers and polars' expectations.

Related errors


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

Appendix: source

Thrown at py-polars/src/polars/io/iceberg/_utils.py:592

        for stats in self.file_column_statistics.values():
            stats.push_file_statistics(file)

    def finish(
        self,
        expected_height: int,
        identity_transformed_values: dict[int, pl.Series | str],
    ) -> pl.DataFrame:
        import polars as pl

        out: list[pl.DataFrame] = [
            pl.Series("len", self.file_lengths, dtype=pl.UInt32).to_frame()
        ]

        for field_id, stat_builder in self.file_column_statistics.items():
            if (p := identity_transformed_values.get(field_id)) is not None:
                if isinstance(p, str):
                    msg = f"statistics load failure for filter column: {p}"
                    raise ComputeError(msg)

            column_stats_df = stat_builder.finish(expected_height, p)
            out.append(column_stats_df)

        return pl.concat(out, how="horizontal")


@dataclass
class IcebergColumnStatisticsLoader:
    column_name: str
    column_dtype: pl.DataType
    field_id: int
    load_from_bytes_impl: LoadFromBytesImpl | None
    null_count: list[int | None]
    min_values: list[bytes | None]
    max_values: list[bytes | None]

    def push_file_statistics(self, file: DataFile) -> None:

View on GitHub (pinned to fe841f959e)