wjones127 commented on a change in pull request #12007: URL: https://github.com/apache/arrow/pull/12007#discussion_r777643176
########## File path: python/pyarrow/tests/test_array.py ########## @@ -2643,6 +2643,30 @@ def test_fixed_size_list_array_flatten(): assert arr2.flatten().flatten().equals(arr0) +def test_map_array_flatten(): + ty = pa.map_(pa.utf8(), pa.int32()) + ty_values = pa.struct([pa.field("key", pa.utf8(), nullable=False), + pa.field("value", pa.int32())]) + a = pa.array([[('a', 1), ('b', 2)], [('c', 3)]], type=ty) + + assert a.values.type.equals(ty_values) + assert a.values == pa.array([ + {'key': 'a', 'value': 1}, + {'key': 'b', 'value': 2}, + {'key': 'c', 'value': 3}, + ], type=ty_values) + assert a.keys.equals(pa.array(['a', 'b', 'c'])) + assert a.items.equals(pa.array([1, 2, 3], type=pa.int32())) + + assert pa.ListArray.from_arrays(a.offsets, a.keys).equals( + pa.array([['a', 'b'], ['c']])) + assert pa.ListArray.from_arrays(a.offsets, a.items).equals( + pa.array([[1, 2], [3]], type=pa.list_(pa.int32()))) + + with pytest.raises(NotImplementedError): + a.flatten() Review comment: We don't have a compute kernel for flatten that takes a map, but I think that's *okay* since typically you want the flattened keys and items, which you *can* get. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org