hililiwei commented on code in PR #8174:
URL: https://github.com/apache/iceberg/pull/8174#discussion_r1291030341


##########
python/pyiceberg/table/__init__.py:
##########
@@ -841,3 +868,210 @@ def to_ray(self) -> ray.data.dataset.Dataset:
         import ray
 
         return ray.data.from_arrow(self.to_arrow())
+
+
+class _SchemaUpdate(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 = last_column_id
+        else:
+            self._last_column_id = schema.highest_field_id
+
+        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 case_sensitive(self, case_sensitive: bool) -> UpdateSchema:
+        self._case_sensitive = case_sensitive
+        return self
+
+    def add_column(
+        self, name: str, type_var: IcebergType, doc: Optional[str] = None, 
parent: Optional[str] = None
+    ) -> UpdateSchema:
+        if "." in name:
+            raise ValueError(f"Cannot add column with ambiguous name: {name}")
+
+        self._internal_add_column(parent, name, True, type_var, doc)
+        return self
+
+    def add_required_column(
+        self, name: str, type_var: IcebergType, doc: Optional[str] = None, 
parent: Optional[str] = None
+    ) -> UpdateSchema:
+        if "." in name:
+            raise ValueError(f"Cannot add column with ambiguous name: {name}")
+
+        if not self._allow_incompatible_changes:
+            raise ValueError(f"Incompatible change: cannot add required 
column: {name}")

Review Comment:
   I think so. I added a comment stating that in versions 1 and 2, adding 
required columns is not allowed by default because there is no initial value.
   
   



-- 
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