From 877347bfc7c37e4ea65f89a37b60cfbdc5dab769 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sat, 30 Mar 2024 19:58:12 -0700 Subject: [PATCH] call as_arrow() once --- 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 b20ea22674..a9f655ed20 100644 --- a/pyiceberg/table/__init__.py +++ b/pyiceberg/table/__init__.py @@ -1173,8 +1173,9 @@ def overwrite( _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: