Skip to content

Commit ddd7bcb

Browse files
committed
fix
1 parent af2dd4a commit ddd7bcb

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pyiceberg/table/update/schema.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,13 @@ def _reset_state(self) -> None:
146146
"""
147147
self._init_state_from_metadata(self._provided_schema)
148148

149-
# Refresh name mapping from the latest table metadata to avoid overwriting concurrent changes
149+
# Refresh name mapping from the latest table metadata to avoid overwriting concurrent changes.
150150
if self._name_mapping is not None:
151-
self._name_mapping = self._transaction.table_metadata.name_mapping()
151+
refreshed_mapping = self._transaction.table_metadata.name_mapping()
152+
153+
# Check refreshed_mapping because if another transaction removes schema.name-mapping.default, refreshed_mapping may become null.
154+
if refreshed_mapping is not None:
155+
self._name_mapping = refreshed_mapping
152156

153157
for operation in self._operations:
154158
op_type = operation[0]

pyiceberg/table/update/snapshot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,10 +1109,11 @@ def _reset_state(self) -> None:
11091109
"""Clear accumulated updates for retry.
11101110
11111111
The _snapshot_ids_to_expire are user-provided and preserved.
1112-
The _updates are cleared so _commit() can rebuild them with
1112+
The _updates and _requirements are cleared so _commit() can rebuild them with
11131113
refreshed protected snapshot IDs.
11141114
"""
11151115
self._updates = ()
1116+
self._requirements = ()
11161117

11171118
def _commit(self) -> UpdatesAndRequirements:
11181119
"""

pyiceberg/table/update/spec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ def add_field(
153153
transform: str | Transform[Any, Any],
154154
partition_field_name: str | None = None,
155155
) -> UpdateSpec:
156-
transform = parse_transform(transform)
156+
if isinstance(transform, str):
157+
transform = parse_transform(transform)
157158
self._operations.append(("add", source_column_name, transform, partition_field_name))
158159
self._do_add_field(source_column_name, transform, partition_field_name)
159160
return self

0 commit comments

Comments
 (0)