DG47 opened a new pull request, #4537:
URL: https://github.com/apache/iceberg-python/pull/4537
<!-- In the case this PR will resolve an issue, please replace
${GITHUB_ISSUE_ID} below with the actual Github issue id. -->
Closes #4536
# Rationale for this change
`PartitionKey.partition` looked up each partition field by its source column
and raised `Cannot have redundant partitions` when the spec had more than one
field on that column. Specs like `bucket(id)` plus `truncate(id)` are valid,
and Java and Spark write them. A format v1 table also ends up with one whenever
a partition field on a column is replaced, for example to change the bucket
count, because the removed field stays in the spec as a `void` transform of the
same column. Appends, overwrites and deletes that rewrite part of a data file
all failed on these tables.
Each `PartitionFieldValue` already carries the partition field it was
computed for, so `PartitionKey.partition` now uses that field instead of
looking it up by source column. Specs with one field per source column produce
the same partition records as before.
An earlier attempt at this, #4092, was closed by the stale bot without
review.
## Are these changes tested?
Yes. `test_append_to_table_with_multiple_partition_fields_on_one_column` in
`tests/catalog/test_catalog_behaviors.py` runs against the memory and SQL
catalogs. It appends to a table partitioned by `bucket(4, id)` and
`truncate(10, id)` and checks the partition values and a filtered scan. It then
changes the bucket count of a format v1 table, appends again, and checks the
new partition values (`null` for the void field) and the rows. The test fails
on main with the `ValueError` and passes with this change.
`make lint` passes, and `make test` gives 4965 passed, 6 skipped, 129
deselected.
## Are there any user-facing changes?
Yes. Writes to tables with more than one partition field on the same column
now succeed instead of raising `ValueError`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]