-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql odd case of rounding compared to duckdb and postgresql #13781
Comments
Another version of what I think may be the same thing:
Datafusion: > SELECT DISTINCT - ( 43 ) * 42 + - + NULLIF ( + 90, - 49 - + CAST ( - - 99 AS REAL ) ) / - + 7, 35 + + 55 AS col1;
+----------------------------------------------------------------------------------------------+------+
| (- Int64(43)) * Int64(42) + (- nullif(Int64(90),Int64(-49) - (- Int64(-99)))) / (- Int64(7)) | col1 |
+----------------------------------------------------------------------------------------------+------+
| -1793.1428 | 90 |
+----------------------------------------------------------------------------------------------+------+ duckdb and postgres: D SELECT DISTINCT - ( 43 ) * 42 + - + NULLIF ( + 90, - 49 - + CAST ( - - 99 AS REAL ) ) / - + 7, 35 + + 55 AS col1;
┌────────────────────────────────────────────────────────────────────────────────┬───────┐
│ ((-43 * 42) + (-(+("nullif"(+(90), (-49 - +(CAST(99 AS FLOAT)))))) / -(+(7)))) │ col1 │
│ double │ int32 │
├────────────────────────────────────────────────────────────────────────────────┼───────┤
│ -1793.142857142857 │ 90 │
└────────────────────────────────────────────────────────────────────────────────┴───────┘
`` |
I suspect much of this is the same cause as #13780 - nullif typing being incorrect and real mapping to f32 where it is not possible to represent some integers exactly. Postgresql also seems to have an interesting casting behavior that if you case an int to a real it may ignore it and implicitly cast it back to an int as long as there is no dependency requiring it to be a real (division for example) |
Resolved as fixed with change 'as REAL' to 'AS FLOAT8' in sqlite test files |
Describe the bug
datafusion
duckdb and postgres:
I cannot determine why df is rounding the result to 2 decimal places.
To Reproduce
sql above.
Expected behavior
results match other databases
Additional context
No response
The text was updated successfully, but these errors were encountered: