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

David Li resolved ARROW-14778.
------------------------------
    Fix Version/s: 7.0.0
       Resolution: Fixed

Issue resolved by pull request 11754
[https://github.com/apache/arrow/pull/11754]

> [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
>            Assignee: David Li
>            Priority: Major
>              Labels: pull-request-available, query-engine
>             Fix For: 7.0.0
>
>          Time Spent: 2h
>  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