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/05/18 14:47:00 UTC
[jira] [Comment Edited] (ARROW-10640) [C++] A "where" kernel to
combine two arrays based on a mask
[ https://issues.apache.org/jira/browse/ARROW-10640?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17346972#comment-17346972 ]
David Li edited comment on ARROW-10640 at 5/18/21, 2:46 PM:
------------------------------------------------------------
I think to summarize the discussion (including from the PR), we can call this {{if_else}} which uses a Boolean mask to select from one of two input arrays/scalars.
A null mask value outputs a null.
A True mask value outputs the LHS scalar/corresponding value from the LHS array.
A False mask value outputs the RHS scalar/corresponding value from the RHS value.
Hence:
{noformat}
if_else([True, False, null], 1, 0) -> [1, 0, null]
if_else([True, False, null], null, 0) -> [null, 0, null]
if_else([True, False, null], 1, null) -> [1, null, null{noformat}
We can file separate issues for CASE WHEN/choose.
was (Author: lidavidm):
I think to summarize the discussion (including from the PR), we can call this {{if_else}} which uses a Boolean mask to select from one of two input arrays/scalars.
A null mask value outputs a null.
A True mask value outputs the LHS scalar/corresponding value from the LHS array.
A False mask value outputs the RHS scalar/corresponding value from the RHS value.
Hence:
{noformat}
if_else([True, False, null], 1, 0) -> [1, 0, null]
if_else
We can file separate issues for CASE WHEN/choose.{noformat}
> [C++] A "where" kernel to combine two arrays based on a mask
> ------------------------------------------------------------
>
> Key: ARROW-10640
> URL: https://issues.apache.org/jira/browse/ARROW-10640
> Project: Apache Arrow
> Issue Type: New Feature
> Components: C++
> Reporter: Joris Van den Bossche
> Priority: Major
>
> (from discussion in ARROW-9489 with [~maartenbreddels])
> A general "where" kernel like {{np.where}} (https://numpy.org/doc/stable/reference/generated/numpy.where.html) seems a generally useful kernel to have, and could also help mimicking some other python (setitem-like) operations.
> The concrete use case in ARROW-9489 is to basically do a {{fill_null(array[string], array[string])}} which could be expressed as {{where(is_null(arr), arr2, arr)}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)