You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Jonathan Keane (Jira)" <ji...@apache.org> on 2021/09/24 17:47:00 UTC
[jira] [Created] (ARROW-14125) [R] Why does round with arithmetic
error?
Jonathan Keane created ARROW-14125:
--------------------------------------
Summary: [R] Why does round with arithmetic error?
Key: ARROW-14125
URL: https://issues.apache.org/jira/browse/ARROW-14125
Project: Apache Arrow
Issue Type: Bug
Reporter: Jonathan Keane
Trying to call {{round}} with an arithmetic expression errors / pulls data into R:
{code}
> library(arrow)
> library(dplyr)
>
> df <- tibble(x = c(-1, -0.55, -0.5, -0.1, 0, 0.1, 0.5, 0.55, 1, NA, NaN))
>
> # Round with arith inside pulls into R
> Table$create(df) %>%
+ mutate(
+ r = round(x + 1)
+ ) %>%
+ collect()
Warning: Expression round(x + 1) not supported in Arrow; pulling data into R
# A tibble: 11 × 2
x r
<dbl> <dbl>
1 -1 0
2 -0.55 0
3 -0.5 0
4 -0.1 1
5 0 1
6 0.1 1
7 0.5 2
8 0.55 2
9 1 2
10 NA NA
11 NaN NaN
>
> Table$create(df) %>%
+ mutate(
+ r = round(0.00001 + 1)
+ ) %>%
+ collect()
Warning: Expression round(1e-05 + 1) not supported in Arrow; pulling data into R
# A tibble: 11 × 2
x r
<dbl> <dbl>
1 -1 1
2 -0.55 1
3 -0.5 1
4 -0.1 1
5 0 1
6 0.1 1
7 0.5 1
8 0.55 1
9 1 1
10 NA 1
11 NaN 1
{code}
However truncate works just fine:
{code}
> Table$create(df) %>%
+ mutate(
+ r = trunc(0.00001 + 1)
+ ) %>%
+ collect()
# A tibble: 11 × 2
x r
<dbl> <dbl>
1 -1 1
2 -0.55 1
3 -0.5 1
4 -0.1 1
5 0 1
6 0.1 1
7 0.5 1
8 0.55 1
9 1 1
10 NA 1
11 NaN 1
>
>
> Table$create(df) %>%
+ mutate(
+ r = trunc(x + 1)
+ ) %>% collect()
# A tibble: 11 × 2
x r
<dbl> <dbl>
1 -1 0
2 -0.55 0
3 -0.5 0
4 -0.1 0
5 0 1
6 0.1 1
7 0.5 1
8 0.55 1
9 1 2
10 NA NA
11 NaN NaN
>
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)