This is an automated email from the ASF dual-hosted git repository.

honahx pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 7fcdb8d2 call as_arrow() once (#565)
7fcdb8d2 is described below

commit 7fcdb8d25dfa2498ba98a2b8e8d2b327d85fa7c9
Author: Kevin Liu <[email protected]>
AuthorDate: Sat Mar 30 20:23:21 2024 -0700

    call as_arrow() once (#565)
---
 pyiceberg/table/__init__.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py
index b20ea226..a9f655ed 100644
--- a/pyiceberg/table/__init__.py
+++ b/pyiceberg/table/__init__.py
@@ -1173,8 +1173,9 @@ class Table:
 
         _check_schema_compatible(self.schema(), other_schema=df.schema)
         # cast if the two schemas are compatible but not equal
-        if self.schema().as_arrow() != df.schema:
-            df = df.cast(self.schema().as_arrow())
+        table_arrow_schema = self.schema().as_arrow()
+        if table_arrow_schema != df.schema:
+            df = df.cast(table_arrow_schema)
 
         with self.transaction() as txn:
             with 
txn.update_snapshot(snapshot_properties=snapshot_properties).overwrite() as 
update_snapshot:

Reply via email to