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


##########
pyiceberg/catalog/bigquery_metastore.py:
##########
@@ -405,6 +502,35 @@ def _create_table_parameters(self, metadata_file_location: 
str, table_metadata:
 
         return parameters
 
+    def _check_bigquery_commit_status(self, table_ref: TableReference, 
new_metadata_location: str) -> str:
+        try:
+            bq_table = self.client.get_table(table_ref)
+            parameters = (
+                bq_table.external_catalog_table_options.parameters
+                if bq_table.external_catalog_table_options and 
bq_table.external_catalog_table_options.parameters
+                else {}
+            )
+            current_metadata_location = parameters.get(METADATA_LOCATION_PROP)
+            if current_metadata_location == new_metadata_location:
+                return "SUCCESS"
+
+            if not current_metadata_location:
+                return "FAILURE"
+
+            io = self._load_file_io(location=current_metadata_location)
+            current_metadata = 
FromInputFile.table_metadata(io.new_input(current_metadata_location))
+
+            previous_metadata_locations = {log.metadata_file for log in 
current_metadata.metadata_log}
+            previous_metadata_location = 
parameters.get(PREVIOUS_METADATA_LOCATION_PROP)

Review Comment:
   This guard is for commit contention across concurrent writers. Could I 
ignore that scenairo now ?
   
   If Writer A commits M1→M2 and, before A verifies the result, Writer B 
commits M2→M3, A may see the current pointer at M3 and mistakenly think its 
commit failed (which is why checking previous metadata history is needed).



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