Skip to content

Commit 08c5b2d

Browse files
Strip format-version from persisted properties on replace
Match new_table_metadata's behavior of popping format-version before persistence, and validate schema compatibility against the resolved format version at the same site.
1 parent 4278b6a commit 08c5b2d

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

pyiceberg/catalog/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ def _replace_staged_table(
549549
int(requested_format_version) if requested_format_version is not None else existing_metadata.format_version
550550
)
551551
iceberg_schema = self._convert_schema_if_needed(schema, cast(TableVersion, resolved_format_version))
552+
iceberg_schema.check_format_version_compatibility(cast(TableVersion, resolved_format_version))
552553

553554
fresh_schema, _ = assign_fresh_schema_ids_for_replace(
554555
iceberg_schema, existing_metadata.schema(), existing_metadata.last_column_id

pyiceberg/table/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,10 @@ def _initial_changes(
11021102
self._updates += (SetLocationUpdate(location=new_location),)
11031103

11041104
# Merge properties (SetPropertiesUpdate merges onto existing properties).
1105-
if new_properties:
1106-
self._updates += (SetPropertiesUpdate(updates=new_properties),)
1105+
# Strip `format-version` so it does not get persisted as a regular property.
1106+
persisted_properties = {k: v for k, v in new_properties.items() if k != TableProperties.FORMAT_VERSION}
1107+
if persisted_properties:
1108+
self._updates += (SetPropertiesUpdate(updates=persisted_properties),)
11071109

11081110
@staticmethod
11091111
def _find_matching_schema_id(table_metadata: TableMetadata, schema: Schema) -> int | None:

0 commit comments

Comments
 (0)