Repository navigation
Description
Apache Iceberg version
0.8.1 (latest release)
Please describe the bug 🐞
Given a simple schema with a DayTransform over a Timestamp column, an error is thrown during write related to mixing downcasted and non-downcasted timestamps.
This would also be resolved with support for nanosecond timestamp types.
schema = Schema(
NestedField(field_id=1, name='timestamp', field_type=TimestampType(), required=False),
)
partition_spec = PartitionSpec(
PartitionField(source_id=1, field_id=1001, transform=DayTransform(), name='date'),
)
schema = pa.schema([pa.field('timestamp', pa.timestamp('ns'))])
data = pa.Table.from_pydict({'timestamp': [1]}, schema=schema)
table.append(data).local/lib/python3.10/site-packages/pyiceberg/table/init.py:984: in append
tx.append(df=df, snapshot_properties=snapshot_properties)
.local/lib/python3.10/site-packages/pyiceberg/table/init.py:417: in append
for data_file in data_files:
.local/lib/python3.10/site-packages/pyiceberg/io/pyarrow.py:2636: in _dataframe_to_data_files
partitions = _determine_partitions(spec=table_metadata.spec(), schema=table_metadata.schema(), arrow_table=df)
.local/lib/python3.10/site-packages/pyiceberg/io/pyarrow.py:2715: in _determine_partitions
partition_values_table = pa.table({
.local/lib/python3.10/site-packages/pyiceberg/io/pyarrow.py:2716: in
str(partition.field_id): partition.transform.pyarrow_transform(field.field_type)(arrow_table[field.name])
.local/lib/python3.10/site-packages/pyiceberg/transforms.py:560: in
return lambda v: pc.days_between(pa.scalar(epoch), v) if v is not None else None
.local/lib/python3.10/site-packages/pyarrow/compute.py:247: in wrapper
return func.call(args, None, memory_pool)
pyarrow/_compute.pyx:393: in pyarrow._compute.Function.call
???
pyarrow/error.pxi:155: in pyarrow.lib.pyarrow_internal_check_status
???
E pyarrow.lib.ArrowNotImplementedError: Function 'days_between' has no kernel matching input types (timestamp[us], timestamp[ns])
pyarrow/error.pxi:92: ArrowNotImplementedError
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
Activity
kevinjqliu commentedon Feb 8, 2025
Currently Iceberg does not have nanosecond support
https://py.iceberg.apache.org/configuration/#nanoseconds-support
To compensate, we can automatically downcast to microsecond on write by setting the config described in the doc
b-phi commentedon Feb 10, 2025
Thanks Kevin, I should have been more clear. I am using the downcasting functionality, which works great for unpartitioned tables. Even an
IdentityTransform()partition over a downcasted timestamp column works fine, but any of the time truncations likeDayTransformorYearTransformresult in the arrow kernel error above.A table with the partition spec will handle downcasting timestamps correctly on write
But this partition spec throws the error
The write code
codrut20 commentedon Apr 11, 2025
I had the same issue with all types of Time partitions and data with
nsunit. Looking at the code it seems that the downcast property is used when checking then schema and when writing the table data, but not when determining the partitions, so I get errors like :Function 'years_between' has no kernel matching input types (timestamp[us], timestamp[ns])jmontalvo94 commentedon Jul 16, 2025
I have the exact same error, trying to append a table with
timestamp[ns]into an Iceberg table withtimestamp(so, trying to use the automatic downcast) but it fails since thePartitionSpecalso includes aDayTransform()as OP suggested.github-actions commentedon Jan 14, 2026
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
github-actions commentedon Jan 28, 2026
This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'