Open acquamarin opened 1 month ago
The crux of the problem here is that literals are still interpreted as DOUBLE, whereas in DuckDB, they're interpreted as DECIMAL.
In bug 1 and 2, the issue is that there is then floating point imprecision when you attempt to cast the doubles to decimals.
In bug 3, the only reason DuckDB gives the correct result is because the arithmetic is DECIMAL arithmetic.
select cast(1 as decimal (32, 1)) + 9007199254740992.0000::double;
Gives the same result we give.
The crux of the problem here is that literals are still interpreted as DOUBLE, whereas in DuckDB, they're interpreted as DECIMAL. I think we should be smart about how we interpret those numbers.
Changing the default interpretation to decimal breaks a lot of things. I'm not sure where to interpret the number as a decimal in this case. Perhaps when it comes to inserting into something with a known schema, we should interpret literals as a string and then apply casting.
Edit: Xiyang told me this solution is really slow. We may have to delay this fix until after the release.
Kùzu version
master
What operating system are you using?
macOS M1
What happened?
bug1.
Should throw an exception since 100000000000000000000000000000000000000.000000000000000000000000000000 is out of range.
bug2.
should throw an exception as well
bug3. incorrect result when adding decimal with double: kuzu:
duckdb:
Are there known steps to reproduce?
No response