andygrove opened a new issue, #4035:
URL: https://github.com/apache/arrow-datafusion/issues/4035
**Describe the bug**
Decimal multiplied by Float produces incorrect results
**To Reproduce**
Using benchmark data, define with decimal field:
```
❯ create external table partsupp (ps_partkey int, ps_suppkey int,
ps_availqty int, ps_supplycost decimal(12,2), ps_comment varchar) stored as csv
with delimiter '|' location '../benchmarks/data/partsupp.csv';
0 rows in set. Query took 0.000 seconds.
❯ select
sum(ps_supplycost)
from
partsupp;
+-----------------------------+
| SUM(partsupp.ps_supplycost) |
+-----------------------------+
| 400420638.54 |
+-----------------------------+
1 row in set. Query took 0.224 seconds.
❯ select
sum(ps_supplycost) * 1.1
from
partsupp;
+--------------------------------------------+
| SUM(partsupp.ps_supplycost) * Float64(1.1) |
+--------------------------------------------+
| 1206.65153731696031007 |
+--------------------------------------------+
1 row in set. Query took 0.246 seconds.
```
The result here is clearly wrong.
It works fine if the column is defined as float rather than decimal.
```
❯ create external table partsupp (ps_partkey int, ps_suppkey int,
ps_availqty int, ps_supplycost float, ps_comment varchar) stored as csv with
delimiter '|' location '../benchmarks/data/partsupp.csv';
0 rows in set. Query took 0.000 seconds.
❯ select
sum(ps_supplycost)
from
partsupp;
+-----------------------------+
| SUM(partsupp.ps_supplycost) |
+-----------------------------+
| 400420638.53610957 |
+-----------------------------+
1 row in set. Query took 0.183 seconds.
❯ select
sum(ps_supplycost) * 1.1
from
partsupp;
+--------------------------------------------+
| SUM(partsupp.ps_supplycost) * Float64(1.1) |
+--------------------------------------------+
| 440462702.38972056 |
+--------------------------------------------+
1 row in set. Query took 0.174 seconds.
```
**Expected behavior**
A clear and concise description of what you expected to happen.
**Additional context**
Add any other context about the problem here.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]