syahra712 commented on code in PR #4118:
URL: https://github.com/apache/iceberg-python/pull/4118#discussion_r4306943443
##########
pyiceberg/io/pyarrow.py:
##########
@@ -2120,7 +2120,16 @@ def map(
)
if isinstance(value_result, pa.StructArray):
# Arrow does not allow reordering of fields, therefore we have
to copy the array :(
- return pa.MapArray.from_arrays(map_array.offsets, key_result,
value_result, arrow_field)
+ projected = pa.MapArray.from_arrays(map_array.offsets,
key_result, value_result, arrow_field)
+ # Keep the validity and offsets buffers of the original array,
otherwise null maps become empty maps
+ return pa.Array.from_buffers(
+ projected.type,
+ len(map_array),
+ map_array.buffers()[:2],
+ map_array.null_count,
+ map_array.offset,
+ [projected.values],
+ )
Review Comment:
Thanks, that's cleaner. It skips building the intermediate MapArray. Applied
in 59f8d82, and the map tests still pass.
--
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]