jorisvandenbossche opened a new issue, #36045:
URL: https://github.com/apache/arrow/issues/36045
Trying to use `pc.map_lookup` today, I noticed some minor usability issues
that could be improved:
```
arr = pa.array([{'a': 'a1', 'b': 'b1'}, {'a': 'a2', 'b': 'b2'}, {'a': 'a1',
'b': 'b3'}],
type=pa.map_(pa.string(), pa.string()))
```
1\. Passing the key value as a python string instead of scalar errors:
```
# works fine
>>> pc.map_lookup(arr, pa.scalar("a"), "all")
<pyarrow.lib.ListArray object at 0x7f099d2fabc0>
[
[
"a1"
],
[
"a2"
],
[
"a1"
]
]
# gives confusing error
>>> pc.map_lookup(arr, "a", "all")
...
ArrowInvalid: map_lookup: query_key can't be empty.
```
If not passing a Scalar object, we should probably just pass the python
value to `pa.scalar(..)` for convenience.
2. Allow to specify the `occurence` keyword, given that this is not
necessarily obvious, it's nice to be able to specify the named argument:
```
>>> pc.map_lookup(arr, pa.scalar("a"), occurence="first")
...
TypeError: __init__() takes exactly 3 positional arguments (2 given)
```
I suppose we need to give it a default value for this, though (to make our
auto-generation work, or we can look into improving the autogeneration of the
signature)
--
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]