Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the use of last-column-id #1367

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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