You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Dewey Dunnington (Jira)" <ji...@apache.org> on 2021/12/09 01:19:00 UTC

[jira] [Commented] (ARROW-15014) [C++] No kernel for logical operations on integer storage of boolean values

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

Dewey Dunnington commented on ARROW-15014:
------------------------------------------

Edited to highlight the C++ side!

> [C++] No kernel for logical operations on integer storage of boolean values
> ---------------------------------------------------------------------------
>
>                 Key: ARROW-15014
>                 URL: https://issues.apache.org/jira/browse/ARROW-15014
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++, R
>            Reporter: Dewey Dunnington
>            Priority: Minor
>
> In R, we can use integers and doubles as input to logical functions like {{&}}, {{|}}, and {{!}}. In Arrow, there is no kernel for non-bool storage of logical values and we get an error if we try.
> In the R bindings this affects some of our translations that error if we pass numbers in. Perhaps not high priority, but ran into this when prototyping zero-copy conversion of logicals to Arrow (since they're stored as an int32 array under the hood) and spending some quality time with the behaviour of R's binary operators. A workaround from the R side is to cast to boolean in all our translations for compute functions that require a logical.
> A few examples:
> {code:R}
> library(arrow, warn.conflicts = FALSE)
> library(dplyr, warn.conflicts = FALSE)
> Scalar$create(0L) | Scalar$create(1L)
> #> Error: NotImplemented: Function or_kleene has no kernel matching input types (scalar[int32], scalar[int32])
> #> /Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/function.cc:215  DispatchBest(&inputs)
> record_batch(numbers = c(0, 1, NA)) %>% 
>   mutate(!numbers)
> #> Error: NotImplemented: Function invert has no kernel matching input types (array[double])
> #> /Users/deweydunnington/Desktop/rscratch/arrow/cpp/src/arrow/compute/exec/expression.cc:340  call.function->DispatchBest(&descrs)
> tibble(numbers = c(0, 1, NA)) %>% 
>   mutate(!numbers)
> #> # A tibble: 3 × 2
> #>   numbers `!numbers`
> #>     <dbl> <lgl>     
> #> 1       0 TRUE      
> #> 2       1 FALSE     
> #> 3      NA NA
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)