Skip to content

Commit 3b559c4

Browse files
authored
Deprecate the use of last-column-id (apache#1367)
This should not be part of the public API: apache/iceberg#11514 This PR depends on a later version of the REST catalog for the integration tests.
1 parent bb078cf commit 3b559c4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

pyiceberg/table/update/__init__.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ class AddSchemaUpdate(IcebergBaseModel):
8888
action: Literal["add-schema"] = Field(default="add-schema")
8989
schema_: Schema = Field(alias="schema")
9090
# This field is required: https://github.com/apache/iceberg/pull/7445
91-
last_column_id: int = Field(alias="last-column-id")
91+
last_column_id: Optional[int] = Field(
92+
alias="last-column-id",
93+
default=None,
94+
deprecated=deprecation_notice(
95+
deprecated_in="0.9.0",
96+
removed_in="0.10.0",
97+
help_message="last-field-id is handled internally, and should not be part of the update.",
98+
),
99+
)
92100

93101
initial_change: bool = Field(
94102
default=False,
@@ -318,11 +326,8 @@ def _(update: RemovePropertiesUpdate, base_metadata: TableMetadata, context: _Ta
318326

319327
@_apply_table_update.register(AddSchemaUpdate)
320328
def _(update: AddSchemaUpdate, base_metadata: TableMetadata, context: _TableMetadataUpdateContext) -> TableMetadata:
321-
if update.last_column_id < base_metadata.last_column_id:
322-
raise ValueError(f"Invalid last column id {update.last_column_id}, must be >= {base_metadata.last_column_id}")
323-
324329
metadata_updates: Dict[str, Any] = {
325-
"last_column_id": update.last_column_id,
330+
"last_column_id": max(base_metadata.last_column_id, update.schema_.highest_field_id),
326331
"schemas": base_metadata.schemas + [update.schema_],
327332
}
328333

0 commit comments

Comments
 (0)