{"record":{"id":"29177b285b0bb00b","repo":"pola-rs/polars","slug":"statistics-load-failure-for-filter-column-p","errorCode":null,"errorMessage":"statistics load failure for filter column: {p}","messagePattern":"statistics load failure for filter column: (.+?)","errorType":"exception","errorClass":"ComputeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/iceberg/_utils.py","lineNumber":592,"sourceCode":"        for stats in self.file_column_statistics.values():\n            stats.push_file_statistics(file)\n\n    def finish(\n        self,\n        expected_height: int,\n        identity_transformed_values: dict[int, pl.Series | str],\n    ) -> pl.DataFrame:\n        import polars as pl\n\n        out: list[pl.DataFrame] = [\n            pl.Series(\"len\", self.file_lengths, dtype=pl.UInt32).to_frame()\n        ]\n\n        for field_id, stat_builder in self.file_column_statistics.items():\n            if (p := identity_transformed_values.get(field_id)) is not None:\n                if isinstance(p, str):\n                    msg = f\"statistics load failure for filter column: {p}\"\n                    raise ComputeError(msg)\n\n            column_stats_df = stat_builder.finish(expected_height, p)\n            out.append(column_stats_df)\n\n        return pl.concat(out, how=\"horizontal\")\n\n\n@dataclass\nclass IcebergColumnStatisticsLoader:\n    column_name: str\n    column_dtype: pl.DataType\n    field_id: int\n    load_from_bytes_impl: LoadFromBytesImpl | None\n    null_count: list[int | None]\n    min_values: list[bytes | None]\n    max_values: list[bytes | None]\n\n    def push_file_statistics(self, file: DataFile) -> None:","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/iceberg/_utils.py#L574-L610","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the table's partition/stats metadata (pyiceberg) for the offending field and fix or regenerate statistics","Bypass statistics-based pruning if possible (e.g. disable the relevant filter or re-write table metadata)","Re-write the table with a current pyiceberg version so stats conform to expectations","Report/upgrade — if polars misinterprets valid stats, this may be a polars bug to file"],"exampleFix":"// before\nlf = pl.scan_iceberg(table, filter=bad_filter)  # ComputeError at stats finish\n// after\n# drop the unsupported filter column or fix table stats first\nlf = pl.scan_iceberg(table).filter(pl.col('col'))","handlingStrategy":"try-catch","validationCode":"# inspect identity partition fields before scanning\nfor field in table.metadata.partition_fields():\n    print(field.field_id, field.transform)  # confirm identity transforms/stats look sane","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.scan_iceberg(table).collect()\nexcept pl.exceptions.ComputeError as e:\n    if 'statistics load failure' in str(e):\n        df = pl.from_arrow(table.scan().to_arrow())  # bypass stats path","preventionTips":["Keep pyiceberg and polars versions aligned","Re-write table metadata after restores/rollbacks to regenerate consistent stats","Validate partition/stats metadata after external writers touch the table","Fall back to pyiceberg scan when stats-driven reads fail"],"tags":["iceberg","statistics","metadata","filter"],"backgroundTag":"unexpected-response-shape","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"}