You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "jorisvandenbossche (via GitHub)" <gi...@apache.org> on 2023/06/13 11:10:17 UTC

[GitHub] [arrow] jorisvandenbossche opened a new issue, #36045: [Python] Improve usability of pc.map_lookup / MapLookupOptions

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: issues-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] jorisvandenbossche commented on issue #36045: [Python] Improve usability of pc.map_lookup / MapLookupOptions

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on issue #36045:
URL: https://github.com/apache/arrow/issues/36045#issuecomment-1589089567

   > 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:
   
   Actually, that errors only because I mis-spelled the keyword name. With the correct name it works:
   
   ```
   >>> pc.map_lookup(arr, pa.scalar("a"), occurrence="all")
   <pyarrow.lib.ListArray object at 0x7f099c96bd00>
   [
     [
       "a1"
     ],
     [
       "a2"
     ],
     [
       "a1"
     ]
   ]
   ```
   
   Wondering if we can provide a better error message in that case, but that might just be a Python/cython behaviour of first checking the positional keywords before the named ones)


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] R-JunmingChen commented on issue #36045: [Python] Improve usability of pc.map_lookup / MapLookupOptions

Posted by "R-JunmingChen (via GitHub)" <gi...@apache.org>.
R-JunmingChen commented on issue #36045:
URL: https://github.com/apache/arrow/issues/36045#issuecomment-1612481122

   take


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] R-JunmingChen commented on issue #36045: [Python] Improve usability of pc.map_lookup / MapLookupOptions

Posted by "R-JunmingChen (via GitHub)" <gi...@apache.org>.
R-JunmingChen commented on issue #36045:
URL: https://github.com/apache/arrow/issues/36045#issuecomment-1612480564

   > 1. Passing the key value as a python string instead of scalar errors:
   So, we should only handle the issue one. I can make a quick implementation for it


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] jorisvandenbossche commented on issue #36045: [Python] Improve usability of pc.map_lookup / MapLookupOptions

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche commented on issue #36045:
URL: https://github.com/apache/arrow/issues/36045#issuecomment-1589097695

   > Wondering if we can provide a better error message in that case, but that might just be a Python/cython behaviour of first checking the positional keywords before the named ones)
   
   Yes, that's a cython issue -> https://github.com/cython/cython/issues/1281


-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow] jorisvandenbossche closed issue #36045: [Python] Improve usability of pc.map_lookup / MapLookupOptions

Posted by "jorisvandenbossche (via GitHub)" <gi...@apache.org>.
jorisvandenbossche closed issue #36045: [Python] Improve usability of pc.map_lookup / MapLookupOptions
URL: https://github.com/apache/arrow/issues/36045


-- 
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: issues-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org