syun64 commented on code in PR #902: URL: https://github.com/apache/iceberg-python/pull/902#discussion_r1672429398
########## pyiceberg/io/pyarrow.py: ########## @@ -1268,14 +1265,8 @@ def __init__(self, file_schema: Schema): def _cast_if_needed(self, field: NestedField, values: pa.Array) -> pa.Array: file_field = self.file_schema.find_field(field.field_id) - if field.field_type.is_primitive: - if field.field_type != file_field.field_type: - return values.cast(schema_to_pyarrow(promote(file_field.field_type, field.field_type), include_field_ids=False)) - elif (target_type := schema_to_pyarrow(field.field_type, include_field_ids=False)) != values.type: Review Comment: That makes sense @Fokko - thank you for the catch! I think this is a [bug I introduced in this PR](https://github.com/apache/iceberg-python/commit/e61ef5770b4d73e683e2c78bebdd6c2165102a6b) when I attempted to remove the field IDs from the read schema without realizing how `to_requested_schema` was being used both for write, as well as for read. I think this could be fixed by exposing `include_field_ids` as an argument to the Visitors and `to_requested_schema` -- 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