[
https://issues.apache.org/jira/browse/ARROW-15014?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dewey Dunnington updated ARROW-15014:
-------------------------------------
Description:
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}
was:
In R, we can use integers and doubles as input to logical functions. In Arrow,
there is no kernel for non-bool storage of logical values. This affects some of
our translations where we might want to cast to {{bool}} rather than error.
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).
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}
> [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)