Skip to content

Commit

Permalink
Deprecate the use of last-column-id (apache#1367)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Fokko authored and sungwy committed Dec 7, 2024
1 parent 4830c4b commit 19d9ff5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pyiceberg/table/update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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_],
}

Expand Down

0 comments on commit 19d9ff5

Please sign in to comment.