-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: integer division returns float, sqllogic test expects int #3271
Comments
Based on how postgres works, I think we should change integer division to return an integer:
|
Since #3543 fixes the original problem, and the proposed new typing system would type division coherently with its operands, is this issue still relevant? |
#3543 was closed. This issue is still relevant. |
See also #6642. |
I don't see MySQL's handling of int division mentioned here yet. MySQL has a similar issue where INT/INT -> REAL. However, they also provide a floor division operator Following this, we could write a script to generate appropriate alternatives for our FLOORDIV operator. This seems like a clean way to handle this issue. |
@knz is this fixed with the |
Yes it is alleviated by |
The following (currently disabled) test performs integer division. Cockroach returns a float instead of the expected int. Integer division is the only binary operator that takes integers and returns a float.
https://github.com/cockroachdb/sqllogictest/blob/a88396b84bb1fe62edf2e072e585d68c0b2ecdca/test/select1.test#L101
I propose allowing the test logic to accept both ints and floats when it expects an int. This would allow any sqllogic test using integer division to succeed. It would be an additional if statement at
cockroach/sql/logic_test.go
Line 460 in 21e3e6c
The text was updated successfully, but these errors were encountered: