HonahX commented on code in PR #807:
URL: https://github.com/apache/iceberg-python/pull/807#discussion_r1637685511
##########
pyiceberg/io/pyarrow.py:
##########
@@ -1167,8 +1197,14 @@ 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 and 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))
+ 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:
+ # if file_field and field type (e.g. String) are the same
Review Comment:
[super small nit] I think it is good to include underscore in both
`file_field` and `field_type`, or remove it from both of them to ensure
consistency.
--
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]