jx2lee commented on code in PR #3099:
URL: https://github.com/apache/iceberg-python/pull/3099#discussion_r3177913394


##########
pyiceberg/catalog/bigquery_metastore.py:
##########
@@ -229,7 +236,88 @@ def drop_table(self, identifier: str | Identifier) -> None:
     def commit_table(
         self, table: Table, requirements: tuple[TableRequirement, ...], 
updates: tuple[TableUpdate, ...]
     ) -> CommitTableResponse:
-        raise NotImplementedError
+        table_identifier = table.name()
+        dataset_name, table_name = 
self.identifier_to_database_and_table(table_identifier, NoSuchTableError)
+        table_ref = TableReference(
+            dataset_ref=DatasetReference(project=self.project_id, 
dataset_id=dataset_name),
+            table_id=table_name,
+        )
+
+        current_bq_table: BQTable | None
+        current_table: Table | None
+        try:
+            current_bq_table = self.client.get_table(table_ref)
+        except NotFound:
+            current_bq_table = None
+            current_table = None
+        else:
+            current_table = 
self._convert_bigquery_table_to_iceberg_table(table_identifier, 
current_bq_table)
+
+        updated_staged_table = self._update_and_stage_table(current_table, 
table_identifier, requirements, updates)
+        if current_table and updated_staged_table.metadata == 
current_table.metadata:
+            return CommitTableResponse(metadata=current_table.metadata, 
metadata_location=current_table.metadata_location)
+
+        self._write_metadata(
+            metadata=updated_staged_table.metadata,
+            io=updated_staged_table.io,
+            metadata_path=updated_staged_table.metadata_location,
+        )
+
+        commit_error: Exception | None = None

Review Comment:
   @rambleraptor I added clean up metadata when commit status failed like java 
implements. 



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