diff --git a/python/pyarrow/_compute.pyx b/python/pyarrow/_compute.pyx index 7e32ba48fbf30..ab63a7a19f7f6 100644 --- a/python/pyarrow/_compute.pyx +++ b/python/pyarrow/_compute.pyx @@ -1565,7 +1565,7 @@ class MapLookupOptions(_MapLookupOptions): Parameters ---------- - query_key : Scalar + query_key : Scalar or Object can be converted to Scalar The key to search for. occurrence : str The occurrence(s) to return from the Map @@ -1573,6 +1573,9 @@ class MapLookupOptions(_MapLookupOptions): """ def __init__(self, query_key, occurrence): + if not isinstance(query_key, lib.Scalar): + query_key = lib.scalar(query_key) + self._set_options(query_key, occurrence) diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index d9209ada24a5c..865fecc7b2291 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -3093,6 +3093,7 @@ def test_map_lookup(): result_all = pa.array([[1], None, None, [5, 7], None], type=pa.list_(pa.int32())) + assert pc.map_lookup(arr, 'one', 'first') == result_first assert pc.map_lookup(arr, pa.scalar( 'one', type=pa.utf8()), 'first') == result_first assert pc.map_lookup(arr, pa.scalar(