kevinjqliu commented on code in PR #523:
URL: https://github.com/apache/iceberg-python/pull/523#discussion_r1538212872


##########
pyiceberg/table/__init__.py:
##########
@@ -1156,7 +1166,9 @@ def overwrite(
         if len(self.spec().fields) > 0:
             raise ValueError("Cannot write to partitioned tables")
 
-        _check_schema(self.schema(), other_schema=df.schema)
+        _check_schema_compatible(self.schema(), other_schema=df.schema)
+        # the two schemas are compatible so safe to cast
+        df = df.cast(self.schema().as_arrow())

Review Comment:
   yea, I like that idea. 
   `_check_schema_compatible` returns a boolean `should_cast`.
   * If schema is exactly the same, return `False` and skip cast
   * If schema is "compatible", return `True` and cast
   * If schema is not "compatible", throws an error



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to