jorisvandenbossche commented on code in PR #14547:
URL: https://github.com/apache/arrow/pull/14547#discussion_r1016460167


##########
python/pyarrow/src/arrow/python/python_to_arrow.cc:
##########
@@ -760,6 +760,11 @@ class PyListConverter : public ListConverter<T, 
PyConverter, PyConverterTrait> {
       RETURN_NOT_OK(AppendSequence(value));
     } else if (PySet_Check(value) || (Py_TYPE(value) == &PyDictValues_Type)) {
       RETURN_NOT_OK(AppendIterable(value));
+    } else if (PyDict_Check(value) && this->options_.type->name() == "map") {

Review Comment:
   ```suggestion
       } else if (PyDict_Check(value) && this->options_.type->id() == 
Type::MAP) {
   ```



##########
python/pyarrow/tests/test_array.py:
##########
@@ -991,6 +991,18 @@ def test_map_labelled():
     assert len(arr) == 2
 
 
+def test_map_from_dict():
+    # ARROW-17832
+    tup_arr = pa.array([[('a', 1), ('b', 2)], [('c', 3)]],
+                       pa.map_(pa.string(), pa.int64()))
+    dict_arr = pa.array([{'a': 1, 'b': 2}, {'c': 3}],
+                        pa.map_(pa.string(), pa.int64()))
+
+    assert tup_arr.type.key_field == dict_arr.type.key_field
+    assert tup_arr.type.item_field == dict_arr.type.item_field
+    assert tup_arr == dict_arr

Review Comment:
   ```suggestion
       assert tup_arr.equals(dict_arr)
   ```
   
   I think this should be sufficient for testing that it worked



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