hililiwei commented on code in PR #8174:
URL: https://github.com/apache/iceberg/pull/8174#discussion_r1300092293
##########
python/pyiceberg/table/__init__.py:
##########
@@ -841,3 +868,239 @@ def to_ray(self) -> ray.data.dataset.Dataset:
import ray
return ray.data.from_arrow(self.to_arrow())
+
+
+class UpdateSchema:
+ def __init__(self, schema: Schema, table: Optional[Table] = None,
last_column_id: Optional[int] = None):
+ self._table = table
+ self._schema = schema
+ if last_column_id:
+ self._last_column_id = itertools.count(last_column_id + 1)
+ else:
+ self._last_column_id = itertools.count(schema.highest_field_id + 1)
+
+ self._identifier_field_names = schema.column_names
+ self._adds: Dict[int, List[NestedField]] = {}
+ self._added_name_to_id: Dict[str, int] = {}
+ self._id_to_parent: Dict[int, str] = {}
+ self._allow_incompatible_changes: bool = False
+ self._case_sensitive: bool = True
+
+ def __exit__(self, _: Any, value: Any, traceback: Any) -> None:
Review Comment:
One question:
For:
```
with table.transaction() as transaction:
transaction.update_schema().add_column("x1", IntegerType(),
"doc").add_column("x2", IntegerType(), "doc").commit()
# now the commit happens because the transaction closes
```
There is no need to return the table, and there is no way to return the
refreshed table.
--
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]