Closed
Description
Describe the bug
This is an odd one that I'm unsure what to make of it
CREATE TABLE tab0(col0 INTEGER, col1 INTEGER, col2 INTEGER);
INSERT INTO tab0 VALUES(97,1,99);
INSERT INTO tab0 VALUES(15,81,47);
INSERT INTO tab0 VALUES(87,21,10);
SELECT DISTINCT + col2 * + col2 * - col2 * col2 * + col2 / + col2 + col0 AS col2 FROM tab0;
results in:
External error: query result mismatch:
[SQL] SELECT DISTINCT + col2 * + col2 * - col2 * col2 * + col2 / + col2 + col0 AS col2 FROM tab0
[Diff] (-expected|+actual)
-4879666
- -96059504
+ -9292487
-9913
at test_files/sqlite/random/aggregates/slt_good_102.slt:15306
Datafusion
> SELECT DISTINCT + col2 * + col2 * - col2 * col2 * + col2 / + col2 + col0 AS col2 FROM tab0;
+----------+
| col2 |
+----------+
| -9292487 |
| -9913 |
| -4879666 |
+----------+
sqlite returns a -96059504 result, both duckdb and postgres fail with integer overflow errors.
I think if a db support integer promotion the result from sqlite is actually correct. I have no idea how DF is coming up with it's result unless it's wrapping the value or truncating it somehow.
To Reproduce
sql above
Expected behavior
No response
Additional context
No response