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


##########
python/pyarrow/_compute.pyx:
##########
@@ -1565,14 +1566,17 @@ 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
         Accepted values are "first", "last", or "all".
     """
 
     def __init__(self, query_key, occurrence):
+        if not issubclass(type(query_key), lib.Scalar):

Review Comment:
   ```suggestion
           if not isinstance(query_key, lib.Scalar):
   ```



##########
python/pyarrow/tests/test_compute.py:
##########
@@ -3092,6 +3092,12 @@ 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,
+                         'one', 'last') == result_last
+    assert pc.map_lookup(arr,
+                         'one', 'all') == result_all

Review Comment:
   Adding just the first case should be sufficient to cover this (the value for 
occurrence shouldn't impact how the query_key is converted)



##########
python/pyarrow/_compute.pyx:
##########
@@ -1565,14 +1566,17 @@ 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
         Accepted values are "first", "last", or "all".
     """
 
     def __init__(self, query_key, occurrence):
+        if not issubclass(type(query_key), lib.Scalar):
+            query_key = pa.scalar(query_key)

Review Comment:
   ```suggestion
               query_key = lib.scalar(query_key)
   ```
   
   and then you don't need to add the `import pyarrow as pa` at the top



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