Repository navigation
Conversation
…lumn After a partition field is removed and its source column is dropped, the old spec's partition field has the unknown type. Rewriting its manifest wrapped the Avro "null" type in another null union, which is invalid Avro and made the table unreadable. Write unknown fields as a plain "null", like Java's AvroSchemaUtil.toOption. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
If you stop partitioning by a column and then drop that column, the next
delete()breaks the table. The commit succeeds, but after that neither PyIceberg nor Spark can read the table.What goes wrong
categoryfield, but the column is gone, so its type becomesunknown.unknownis stored in Avro as"null".["null", <type>], which gives["null", "null"].IndexError, Spark withDuplicate in union:null.When it started
to_bytesforUnknownType#3899 (including the 0.12.0 release): step 3 raises an error. The delete fails, but the table is untouched and still readable.to_bytesforUnknownType#3899 (merged tomain, not released yet): step 3 succeeds but writes a broken manifest, so the whole table becomes unreadable.main. Once 0.13.0 is released, it would affect everyone who upgrades.Fix
unknown, write it as plain"null"with no union. It's changed in the 3 places that build the Avro schema and the writers.NULL(TypeToSchema.java), andNULLis never wrapped in a union (AvroSchemaUtil.java).to_bytesforUnknownType#3899 ported a different part of Java's fix for this bug (Core, Spark: Handle unknown type during deletes iceberg#14356), but not this one.Reports from users
Are these changes tested?
Yes.
tests/avro/test_file.py::test_write_optional_unknown_type: write an optional unknown field, read it back.tests/catalog/test_catalog_behaviors.py::test_delete_after_dropping_old_partition_source_column: the example above, v1 and v2, every catalog fixture.mainand pass with this change (pure Python and Cython Avro decoders).main; the difference is the 7 new tests. 9 other failures are the same on both (optional packages I don't have).rayordaft, which I don't have installed, and fail the same way onmain.main:Duplicate in union:null. This PR:[2]for v1 and v2.ruff checkandruff format --checkpass.Are there any user-facing changes?
Yes, a bug fix.
delete()andoverwrite()after dropping an old partition column now write readable manifests.overwrite()in this case still fails earlier withCould not find field with id: 2, with or without this change. That's a separate issue.["null", "null"]by an unreleasedmainbuild are not repaired.Since #3899 isn't released yet, could this go into the 0.13.0 milestone?
Written with AI assistance (Claude Code, Claude Opus 5.5). The Java references were read from
apache/icebergmain, and the tests above were run on this branch.