Skip to content
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

bitwise* operators won't check arguments type when short circuited (Found by SQLancer-NoREC) #11260

Open
2010YOUY01 opened this issue Jul 4, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@2010YOUY01
Copy link
Contributor

Describe the bug

All bitwise operators https://datafusion.apache.org/user-guide/sql/operators.html#op-bit-and don't allow two arguments both to be Double type, but if the bitwise expression is short-circuited, then type check won't be performed.
This bug can be reproduced with any bitwise operator

> select 3.1<<3.2;
Internal error: Data type Float64 not supported for binary operation 'bitwise_shift_left' on dyn arrays.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
> select (false and (3.1<<3.2) > 0);
+------------------------------------------------------------+
| Boolean(false) AND Float64(3.1) << Float64(3.2) > Int64(0) |
+------------------------------------------------------------+
| false                                                      |
+------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.003 seconds.

It's better to return a planning error, because strictly (3.1<<3.2) should be an invalid expression like the following one, and can't be short-circuited

> select (false and (1 + 'foo'));
Error during planning: Cannot coerce arithmetic expression Int64 + Utf8 to valid types

To Reproduce

No response

Expected behavior

No response

Additional context

Found by SQLancer #11030

@2010YOUY01 2010YOUY01 added the bug Something isn't working label Jul 4, 2024
@dharanad
Copy link
Contributor

dharanad commented Jul 4, 2024

take

@dharanad
Copy link
Contributor

dharanad commented Jul 4, 2024

I plan to close this issue by 7/20. Can unassign myseld if this is a priority

@2010YOUY01
Copy link
Contributor Author

I plan to close this issue by 7/20. Can unassign myseld if this is a priority

I don't think this one is urgent, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants