rdblue commented on code in PR #8374:
URL: https://github.com/apache/iceberg/pull/8374#discussion_r1304994873


##########
python/pyiceberg/table/__init__.py:
##########
@@ -889,28 +888,58 @@ def to_ray(self) -> ray.data.dataset.Dataset:
         return ray.data.from_arrow(self.to_arrow())
 
 
+class MoveOperation(Enum):
+    First = 1
+    Before = 2
+    After = 3
+
+
+@dataclass
+class Move:
+    field_id: int
+    op: MoveOperation
+    other_field_id: Optional[int] = None
+
+
 class UpdateSchema:
     _table: Table
     _schema: Schema
     _last_column_id: itertools.count[int]
-    _identifier_field_names: List[str]
-    _adds: Dict[int, List[NestedField]]
-    _added_name_to_id: Dict[str, int]
-    _id_to_parent: Dict[int, str]
+    _identifier_field_names: Set[str]
+
+    _adds: Dict[int, List[NestedField]] = {}
+    _updates: Dict[int, NestedField] = {}
+    _deletes: Set[int] = set()
+    _moves: Dict[int, List[Move]] = {}
+
+    _added_name_to_id: Dict[str, int] = {}
+    _id_to_parent: Dict[int, str] = {}
     _allow_incompatible_changes: bool
     _case_sensitive: bool
     _transaction: Optional[Transaction]
 
-    def __init__(self, schema: Schema, table: Table, transaction: 
Optional[Transaction] = None):
+    def __init__(
+        self,
+        table: Table,
+        transaction: Optional[Transaction] = None,
+        allow_incompatible_changes: bool = False,
+        case_sensitive: bool = True,
+    ) -> None:
         self._table = table
-        self._schema = schema
-        self._last_column_id = itertools.count(schema.highest_field_id + 1)
-        self._identifier_field_names = schema.column_names
+        self._schema = table.schema()
+        self._last_column_id = itertools.count(self._schema.highest_field_id + 
1)

Review Comment:
   The highest field ID needs to come from the table metadata, not from the 
current schema. Otherwise, an ID could be reassigned if an ID is assigned, the 
schema is rolled back, and another column is added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to