[ 
https://issues.apache.org/jira/browse/ARROW-14778?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated ARROW-14778:
-----------------------------------
    Labels: pull-request-available query-engine  (was: query-engine)

> [C++] mean on a decimal truncates and does not round
> ----------------------------------------------------
>
>                 Key: ARROW-14778
>                 URL: https://issues.apache.org/jira/browse/ARROW-14778
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++
>            Reporter: Jonathan Keane
>            Priority: Major
>              Labels: pull-request-available, query-engine
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> {code}
> library(arrow, warn.conflicts = FALSE)
> library(dplyr, warn.conflicts = FALSE)
> df <- data.frame(
>   x = c(0.1, 0.2, 0.2, 0.2, 0.2)
> )
> tab <- Table$create(df)
> tab %>%
>   summarise(mean(x)) %>% 
>   collect()
> #> # A tibble: 1 × 1
> #>   `mean(x)`
> #>       <dbl>
> #> 1      0.18
> tab %>%
>   summarise(x = mean(x)) %>% 
>   mutate(x = cast(x, decimal(5, 1))) %>% 
>   collect()
> #> # A tibble: 1 × 1
> #>       x
> #>   <dbl>
> #> 1   0.2
> tab %>%
>   mutate(x = cast(x, decimal(5, 1))) %>% 
>   summarise(x = mean(x)) %>% 
>   collect()
> #> # A tibble: 1 × 1
> #>       x
> #>   <dbl>
> #> 1   0.1
> {code}



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

Reply via email to