jo-migo commented on code in PR #47454:
URL: https://github.com/apache/arrow/pull/47454#discussion_r2406704091


##########
python/pyarrow/scalar.pxi:
##########
@@ -1173,7 +1173,7 @@ cdef class MapScalar(ListScalar, Mapping):
         if not maps_as_pydicts:
             return list(self)
         result_dict = {}
-        for key, value in self:
+        for key, value in zip(self.keys(), 
self.values.field(self.type.item_field.name)):

Review Comment:
   As for the context, check out the PR description for a (hopefully) 
straightforward minimal example, but it's just like @jonded94 says. The problem 
with the current implementation is that round trips from python -> arrow -> 
python are broken at the moment for nested map columns ---
   
   basically we want 
   
   ```
   {'x': {'a': {'1': 1}}} -> {'x': {'a': {'1': 1}}}
   ``` 
   
   but the current behaviour with `maps_as_pydicts` is: 
   
   ```
   {'x': {'a': {'1': 1}}} -> {'x': {'a': [('1', 1)]}}
   ```



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

Reply via email to