This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git
The following commit(s) were added to refs/heads/main by this push:
new 3b559c4e Deprecate the use of `last-column-id` (#1367)
3b559c4e is described below
commit 3b559c4e923ca53671bffdf7b12951455af14cae
Author: Fokko Driesprong <[email protected]>
AuthorDate: Tue Nov 26 09:05:30 2024 +0100
Deprecate the use of `last-column-id` (#1367)
This should not be part of the public API:
https://github.com/apache/iceberg/pull/11514
This PR depends on a later version of the REST
catalog for the integration tests.
---
pyiceberg/table/update/__init__.py | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/pyiceberg/table/update/__init__.py
b/pyiceberg/table/update/__init__.py
index b81a2bf7..de9a774e 100644
--- a/pyiceberg/table/update/__init__.py
+++ b/pyiceberg/table/update/__init__.py
@@ -88,7 +88,15 @@ class AddSchemaUpdate(IcebergBaseModel):
action: Literal["add-schema"] = Field(default="add-schema")
schema_: Schema = Field(alias="schema")
# This field is required: https://github.com/apache/iceberg/pull/7445
- last_column_id: int = Field(alias="last-column-id")
+ last_column_id: Optional[int] = Field(
+ alias="last-column-id",
+ default=None,
+ deprecated=deprecation_notice(
+ deprecated_in="0.9.0",
+ removed_in="0.10.0",
+ help_message="last-field-id is handled internally, and should not
be part of the update.",
+ ),
+ )
initial_change: bool = Field(
default=False,
@@ -318,11 +326,8 @@ def _(update: RemovePropertiesUpdate, base_metadata:
TableMetadata, context: _Ta
@_apply_table_update.register(AddSchemaUpdate)
def _(update: AddSchemaUpdate, base_metadata: TableMetadata, context:
_TableMetadataUpdateContext) -> TableMetadata:
- if update.last_column_id < base_metadata.last_column_id:
- raise ValueError(f"Invalid last column id {update.last_column_id},
must be >= {base_metadata.last_column_id}")
-
metadata_updates: Dict[str, Any] = {
- "last_column_id": update.last_column_id,
+ "last_column_id": max(base_metadata.last_column_id,
update.schema_.highest_field_id),
"schemas": base_metadata.schemas + [update.schema_],
}