Fokko commented on code in PR #2662:
URL: https://github.com/apache/iceberg-python/pull/2662#discussion_r2466168619


##########
pyiceberg/io/pyarrow.py:
##########
@@ -2624,8 +2627,41 @@ def _check_pyarrow_schema_compatible(
         )
         additional_names = set(provided_schema._name_to_id.keys()) - 
set(requested_schema._name_to_id.keys())
         raise ValueError(
-            f"PyArrow table contains more columns: {', 
'.join(sorted(additional_names))}. Update the schema first (hint, use 
union_by_name)."
+            f"PyArrow table contains more columns: {', 
'.join(sorted(additional_names))}. "
+            "Update the schema first (hint, use union_by_name)."
         ) from e
+
+    # If the file has explicit field IDs, validate they match the table schema 
exactly
+    if has_field_ids:
+        # Build mappings for both schemas (including nested fields)
+        requested_id_to_name = requested_schema._lazy_id_to_name
+        provided_id_to_name = provided_schema._lazy_id_to_name

Review Comment:
   Hey @jeroko Thanks for working on this, and adding this check.
   
   However, I don't think we really care about the names; it is not a problem 
when they differ. However, if you add a file with a different schema, we can 
brick the table because of issues in the types. Should we check if the file 
contains the expected type for each of the IDs instead?



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