MCPcopy Create free account
hub / github.com/apache/arrow / test_map_lookup

Function test_map_lookup

python/pyarrow/tests/test_compute.py:3834–3849  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3832
3833
3834def test_map_lookup():
3835 ty = pa.map_(pa.utf8(), pa.int32())
3836 arr = pa.array([[('one', 1), ('two', 2)], [('none', 3)],
3837 [], [('one', 5), ('one', 7)], None], type=ty)
3838 result_first = pa.array([1, None, None, 5, None], type=pa.int32())
3839 result_last = pa.array([1, None, None, 7, None], type=pa.int32())
3840 result_all = pa.array([[1], None, None, [5, 7], None],
3841 type=pa.list_(pa.int32()))
3842
3843 assert pc.map_lookup(arr, 'one', 'first') == result_first
3844 assert pc.map_lookup(arr, pa.scalar(
3845 'one', type=pa.utf8()), 'first') == result_first
3846 assert pc.map_lookup(arr, pa.scalar(
3847 'one', type=pa.utf8()), 'last') == result_last
3848 assert pc.map_lookup(arr, pa.scalar(
3849 'one', type=pa.utf8()), 'all') == result_all
3850
3851
3852def test_struct_fields_options():

Callers

nothing calls this directly

Calls 2

arrayMethod · 0.45
scalarMethod · 0.45

Tested by

no test coverage detected