kainoa21 commented on a change in pull request #10981:
URL: https://github.com/apache/arrow/pull/10981#discussion_r694942284



##########
File path: python/pyarrow/types.pxi
##########
@@ -2349,12 +2363,23 @@ cpdef MapType map_(key_type, item_type, 
keys_sorted=False):
     map_type : DataType
     """
     cdef:
-        DataType _key_type = ensure_type(key_type, allow_none=False)
-        DataType _item_type = ensure_type(item_type, allow_none=False)
+        Field _key_field
+        Field _item_field
         shared_ptr[CDataType] map_type
         MapType out = MapType.__new__(MapType)
 
-    map_type.reset(new CMapType(_key_type.sp_type, _item_type.sp_type,
+    if isinstance(key_type, Field):
+        _key_field = key_type

Review comment:
        I wasn't able to reproduce the segfault from this 
[issue](https://issues.apache.org/jira/browse/ARROW-13735).
   
   ```
   >>> t = pa.map_(pa.field("name", "string", nullable=False), "int64")
   >>> pa.array([[('a', 1), ('b', 2)], [('c', 3)]], type=t)
   <pyarrow.lib.MapArray object at 0x12d150220>
   [
     keys:
     [
       "a",
       "b"
     ]
     values:
     [
       1,
       2
     ],
     keys:
     [
       "c"
     ]
     values:
     [
       3
     ]
   ]
   ``` 




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