You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "David Li (Jira)" <ji...@apache.org> on 2021/06/16 16:43:00 UTC

[jira] [Comment Edited] (ARROW-13064) [C++] Add a general "if, ifelse, ..., else" kernel

    [ https://issues.apache.org/jira/browse/ARROW-13064?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17364358#comment-17364358 ] 

David Li edited comment on ARROW-13064 at 6/16/21, 4:42 PM:
------------------------------------------------------------

There's also one complication in that it looks like variadic functions don't currently allow mixed types. So we'll have to extend the kernel infra to allow this, or pack arguments in struct types. (And actually: packing arguments in structs doesn't work here either, because then you can't have an 'else' branch.)


was (Author: lidavidm):
There's also one complication in that it looks like variadic functions don't currently allow mixed types. So we'll have to extend the kernel infra to allow this, or pack arguments in struct types.

> [C++] Add a general "if, ifelse, ..., else" kernel
> --------------------------------------------------
>
>                 Key: ARROW-13064
>                 URL: https://issues.apache.org/jira/browse/ARROW-13064
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++
>            Reporter: Ian Cook
>            Priority: Major
>
> ARROW-10640 added a ternary {{if_else}} kernel. Add another kernel that extends this concept to an arbitrary number of conditions and associated results, like a vectorized {{if-ifelse-...-else}} with an arbitrary number of {{ifelse}} and with the {{else}} optional. This is like a SQL {{CASE}} statement.
> How best to achieve this is not obvious. To enable SQL-style uses, it would be most efficient to implement this as a variadic kernel where the even-number arguments (0, 2, ...) are the arrays of boolean conditions, the odd-number arguments (1, 3, ...) are the corresponding arrays of results, and the final argument is the {{else}} result. But I'm not sure if this is practical. Maybe instead we should implement this to operate on listarrays, like NumPy's {{[np.where|https://numpy.org/doc/stable/reference/generated/numpy.where.html]}} or {{[np.select|https://numpy.org/doc/stable/reference/generated/numpy.select.html]}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)