pola-rs/polars · error · NotImplementedError
sink to Iceberg table with
Error message
sink to Iceberg table with '{transform}' partition transform on '{source_type}' What it means
_partition_key_exprs supports TruncateTransform only for integer (int/long), string, and binary source columns. If the partition spec applies a truncate transform to any other source type (e.g. decimal, double, date), Polars cannot build the partition key expression and raises NotImplementedError. It is a guard against unsupported partition transform/type combinations.
Solutions
- Recreate or alter the target table's partition spec to use truncate only on int/long/string/binary columns (e.g. replace truncate on decimal with identity or a temporal transform).
- Cast the partition source column to a supported type (string for truncation) and update the spec accordingly.
- Sink to an unpartitioned table and partition later via a rewrite/compaction job in your catalog engine.
- Check whether a newer polars/pyiceberg version added support for this transform/type pair.
Example fix
// before: spec truncates a decimal column spec = PartitionSpec(PartitionField(source_id=dec_id, transform=TruncateTransform(10), ...)) // after: use identity on the decimal column spec = PartitionSpec(PartitionField(source_id=dec_id, transform=IdentityTransform(), ...))
Defensive patterns
Strategy: validation
Validate before calling
from pyiceberg.transforms import TruncateTransform
from pyiceberg.types import IntegerType, LongType, StringType, BinaryType
for f in table.spec().fields:
src = table.schema().find_field(f.source_id)
if isinstance(f.transform, TruncateTransform) and not isinstance(
src.field_type, (IntegerType, LongType, StringType, BinaryType)
):
raise ValueError(f"truncate partition on unsupported type {src.field_type}") Type guard
def truncate_supported(field_type) -> bool:
from pyiceberg.types import IntegerType, LongType, StringType, BinaryType
return isinstance(field_type, (IntegerType, LongType, StringType, BinaryType)) Try / catch
try:
lf.sink_iceberg(target_table)
except NotImplementedError as e:
if "partition transform on" in str(e):
target = recreate_table_without_unsupported_partition_transforms(target_table)
lf.sink_iceberg(target)
else:
raise Prevention
- When creating sink target tables, restrict truncate partition transforms to int/long/string/binary columns
- Inspect table.spec() before choosing a sink target
- Avoid copying partition specs verbatim from Spark/Trino tables
When it happens
Trigger: sink_iceberg into a table whose partition spec contains a TruncateTransform W on a source column whose Iceberg type is not IntegerType/LongType/StringType/BinaryType (e.g. truncate on a decimal or float column).
Common situations: Tables partitioned with truncate on decimal columns created by Spark/Trino; copying a spec from another engine where such combinations are legal; manually authoring a partition spec with truncate on a numeric non-integer column.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Iceberg sort transform
- Iceberg sort transform
- sink to Iceberg table with partition field
- sink to Iceberg table with
- Cannot infer partition value from Parquet metadata for…
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/f656332483c7c6fb.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/iceberg/_sink.py:339
if isinstance(transform, IdentityTransform):
pass
elif isinstance(
transform, (YearTransform, MonthTransform, DayTransform, HourTransform)
):
expr = _temporal_transform_expr(expr, source_type, transform)
elif isinstance(transform, TruncateTransform):
if isinstance(source_type, (IntegerType, LongType)):
expr = expr - expr % transform.width
elif isinstance(source_type, StringType):
expr = expr.str.slice(0, transform.width)
elif isinstance(source_type, BinaryType):
expr = expr.bin.slice(0, transform.width)
else:
msg = (
"sink to Iceberg table with "
f"'{transform}' partition transform on '{source_type}'"
)
raise NotImplementedError(msg)
else:
msg = f"sink to Iceberg table with '{transform}' partition transform"
raise NotImplementedError(msg)
key_name = f"__POLARS_ICEBERG_PARTITION_{field.field_id}"
while key_name in reserved_names:
key_name += "_"
reserved_names.add(key_name)
exprs.append(expr.alias(key_name))
return exprs
class _SortTransform:
"""Apply an Iceberg sort transform without pickling its cached callable."""
def __init__(
self, transform: Transform[Any, Any], source_type: IcebergTypeView on GitHub (pinned to fe841f959e)