You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/11/22 21:42:35 UTC
[GitHub] [arrow] lidavidm commented on pull request #11754: ARROW-14778: [C++] Mean of Decimal should be Double
lidavidm commented on pull request #11754:
URL: https://github.com/apache/arrow/pull/11754#issuecomment-975944295
Just for reference it seems DuckDB actually outputs a double:
```
D create table df (dec decimal(3, 2), flt float);
D insert info df (dec, flt) values (0.01, 0.01);
Error: Parser Error: syntax error at or near "info"
LINE 1: insert info df (dec, flt) values (0.01, 0.01);
^
D insert into df (dec, flt) values (0.01, 0.01);
D insert into df (dec, flt) values (0.02, 0.02);
D insert into df (dec, flt) values (0.02, 0.02);
D insert into df (dec, flt) values (0.02, 0.02);
D select typeof(dec), typeof(flt) from df;
┌──────────────┬─────────────┐
│ typeof(dec) │ typeof(flt) │
├──────────────┼─────────────┤
│ DECIMAL(3,2) │ FLOAT │
│ DECIMAL(3,2) │ FLOAT │
│ DECIMAL(3,2) │ FLOAT │
│ DECIMAL(3,2) │ FLOAT │
└──────────────┴─────────────┘
D select avg(dec), avg(flt), typeof(avg(dec)), typeof(avg(flt)) from df;
┌──────────┬─────────────────────┬──────────────────┬──────────────────┐
│ avg(dec) │ avg(flt) │ typeof(avg(dec)) │ typeof(avg(flt)) │
├──────────┼─────────────────────┼──────────────────┼──────────────────┤
│ 0.0175 │ 0.01749999960884452 │ DOUBLE │ DOUBLE │
└──────────┴─────────────────────┴──────────────────┴──────────────────┘
```
We can cast back to Decimal, but how should we round/truncate the result?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org