{"record":{"id":"afcab0822e55bcfe","repo":"pola-rs/polars","slug":"sink-to-iceberg-table-with-transform-partition-afcab0","errorCode":null,"errorMessage":"sink to Iceberg table with '{transform}' partition transform","messagePattern":"sink to Iceberg table with '(.+?)' partition transform","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/iceberg/_sink.py","lineNumber":330,"sourceCode":"                expr = expr.cast(pl.Date).cast(pl.Int32)\n            else:\n                expr = expr.dt.epoch(\"us\") // 3_600_000_000\n        elif isinstance(transform, TruncateTransform):\n            if isinstance(source_type, (IntegerType, LongType)):\n                expr = expr - expr % transform.width\n            elif isinstance(source_type, StringType):\n                expr = expr.str.slice(0, transform.width)\n            elif isinstance(source_type, BinaryType):\n                expr = expr.bin.slice(0, transform.width)\n            else:\n                msg = (\n                    \"sink to Iceberg table with \"\n                    f\"'{transform}' partition transform on '{source_type}'\"\n                )\n                raise NotImplementedError(msg)\n        else:\n            msg = f\"sink to Iceberg table with '{transform}' partition transform\"\n            raise NotImplementedError(msg)\n\n        key_name = f\"__POLARS_ICEBERG_PARTITION_{field.field_id}\"\n        while key_name in reserved_names:\n            key_name += \"_\"\n        reserved_names.add(key_name)\n        exprs.append(expr.alias(key_name))\n\n    return exprs\n\n\n@dataclass(kw_only=True)\nclass IcebergSinkState:\n    py_catalog_class_module: str\n    py_catalog_class_qualname: str\n\n    catalog_name: str\n    catalog_properties: dict[str, str]\n","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/pola-rs/polars/blob/fc24390824009e8fc5b7870e256273c1b140a019/py-polars/src/polars/io/iceberg/_sink.py#L312-L348","documentation":"This is the fallback branch of the same transform-dispatch in `_partition_key_exprs`: the partition field's transform is not one of any supported transform classes, so the sink cannot build a partition key expression at all. It raises NotImplementedError without even a matching source type, meaning the transform itself is entirely unsupported by the sink.","triggerScenarios":"`sink_iceberg` on a table whose partition spec contains a transform the sink has no code path for — e.g. `void` transform, custom/future transform types from newer Iceberg specs, or unknown transform names in the table metadata.","commonSituations":"Tables created by newer Iceberg/Spark versions using transforms polars doesn't support yet; metadata with `void` partition transforms (columns dropped from partitioning); hand-written or migrated table metadata referencing unknown transforms.","solutions":["Check which transform the field uses (`[f.transform for f in table.spec().fields]`) and compare against polars' supported set (identity, bucket, truncate, temporal)","Rebuild the table's partition spec using only supported transforms (identity/bucket/truncate/year/month/day/hour)","Upgrade polars (and pyiceberg) — support for additional transforms is added over time","Materialize the transform yourself into a top-level column and partition with identity transform on it"],"exampleFix":"// before: partition spec uses an unsupported transform\n# partition: void('status')\n// after: rewrite spec with a supported transform\n# partition: identity('status')\nlf.sink_iceberg(table)","handlingStrategy":"validation","validationCode":"SUPPORTED = {'identity', 'bucket', 'truncate', 'year', 'month', 'day', 'hour'}\nfor field in table.spec().fields:\n    if str(field.transform).split('[')[0].strip() not in SUPPORTED:\n        raise ValueError(f\"unsupported partition transform: {field.transform}\")","typeGuard":null,"tryCatchPattern":"try:\n    lf.sink_iceberg(table)\nexcept NotImplementedError as e:\n    if str(e) == \"sink to Iceberg table with '{}' partition transform\".format(e.args[0]) or 'partition transform' in str(e):\n        raise RuntimeError(\"table uses a partition transform unsupported by polars; rebuild spec or upgrade\") from e\n    raise","preventionTips":["List all partition transforms before sinking and reject unknown ones","Keep polars and pyiceberg up to date to pick up newly supported transforms","Avoid tables with void/custom transforms for polars sink workflows"],"tags":["iceberg","partitioning","transform","unsupported","polars"],"backgroundTag":"unsupported-partition-transform","analyzedSha":"fc24390824009e8fc5b7870e256273c1b140a019","analyzedAt":"2026-09-02T20:08:03.494Z","contentChangedAt":"2026-09-02T20:08:03.494Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}