Writing v3 Table Metadata - #3551
Conversation
ebyhr
left a comment
There was a problem hiding this comment.
Does it make sense to add an integration test that Spark reads v3 tables written by PyIceberg?
abnobdoss
left a comment
There was a problem hiding this comment.
This is awesome - I'm excited for v3 table write support! Left a few minor comments; apologies if I misunderstood anything here.
| INITIAL_SPEC_ID = 0 | ||
| DEFAULT_SCHEMA_ID = 0 | ||
|
|
||
| SUPPORTED_TABLE_FORMAT_VERSION = 2 |
There was a problem hiding this comment.
Does this need to change?
There was a problem hiding this comment.
Does this PR only allow new v3 tables or does it also enable v1/v2 tables to be upgraded to v3?
| next_row_id: int | None = Field(alias="next-row-id", default=None) | ||
| """A long higher than all assigned row IDs; the next snapshot's `first-row-id`.""" | ||
|
|
||
| def model_dump_json(self, exclude_none: bool = True, exclude: Any | None = None, by_alias: bool = True, **kwargs: Any) -> str: |
There was a problem hiding this comment.
Is row lineage fully wired up? If I'm not mistaken, row lineage would be a pre-requisite for v3 enablement?
|
The v3 spec marks |
Allow upgrade_table_version(3) and initialize next-row-id to 0 on upgrade, per the spec's Row Lineage for Upgraded Tables. Persisting the upgraded metadata still requires V3 metadata serialization (apache#3551). Closes apache#3622 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Allow upgrade_table_version(3) and initialize next-row-id to 0 on upgrade, per the spec's Row Lineage for Upgraded Tables. Persisting the upgraded metadata still requires V3 metadata serialization (apache#3551). Closes apache#3622
| """A long higher than all assigned row IDs; the next snapshot's `first-row-id`.""" | ||
|
|
||
| def model_dump_json(self, exclude_none: bool = True, exclude: Any | None = None, by_alias: bool = True, **kwargs: Any) -> str: | ||
| raise NotImplementedError("Writing V3 is not yet supported, see: https://github.com/apache/iceberg-python/issues/1551") |
There was a problem hiding this comment.
One edge case this change surfaces: the v3 spec allows an optional encryption-keys list in table metadata, and the Java TableMetadataParser writes it when present. PyIceberg doesn't model the field, and the pydantic models ignore unknown fields, so it's dropped at parse time. With serialization enabled, loading a v3 table that carries encryption-keys and committing any update would rewrite the metadata without the keys, which would break an encrypted table. Would it make sense to add a passthrough encryption-keys field to TableMetadataV3 so it round-trips, even before encryption is actually supported?
|
@rambleraptor gentle ping on this one — it's been quiet for a month and CI is green (17/17). I'm asking because #3623 (upgrading tables to v3) is blocked on it: Is there anything blocking your side, or would it help if I picked up review feedback on it? Happy to help move it along either way. |
Allow upgrade_table_version(3) and initialize next-row-id to 0 on upgrade, per the spec's Row Lineage for Upgraded Tables. Persisting the upgraded metadata still requires V3 metadata serialization (apache#3551). Closes apache#3622
Allow upgrade_table_version(3) and initialize next-row-id to 0 on upgrade, per the spec's Row Lineage for Upgraded Tables. Persisting the upgraded metadata still requires V3 metadata serialization (apache#3551). Closes apache#3622
|
Picking up the thread here, since #3620 / #3621 / #3622 / #3623 are all waiting on this one. @rambleraptor no pressure intended — mostly answering the open review questions so this is easier to land, plus two gaps I think block it as it stands. @abnobdoss on whether this enables upgrades: it does not. @abnobdoss on row lineage being a prerequisite: for data it is not reachable. Gap 1: md = new_table_metadata(schema=..., partition_spec=..., sort_order=..., location=..., properties={"format-version": "3"})
md.next_row_id # None
"next-row-id" in md.model_dump() # False
Gap 2: How would you like to proceed? Any of these works for me: enable maintainer edits and I will push both fixes onto this branch, or I open a PR against your branch so authorship stays with you, or if you would rather hand it off I can carry it forward with credit to you — I have both changes written and tested locally. @ebyhr any preference on the |
Rationale for this change
We're far enough into v3 (with a ratified spec!) that we should consider writing v3 table metadata.
Are these changes tested?
Added a unit test and fixed up the places where we were expecting errors
Are there any user-facing changes?