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/11/19 16:34:00 UTC

[jira] [Updated] (ARROW-14778) [C++] mean on a decimal truncates and does not round

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

Jonathan Keane updated ARROW-14778:
-----------------------------------
    Summary: [C++] mean on a decimal truncates and does not round  (was: [C++] [Compute] mean on a decimal truncates and does not round)

> [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: query-engine
>
> {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)