-
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
UnwrapCastInComparison
produces incorrect results
#14303
Comments
I have analyzed the code in unwrap_cast_in_comparison.rs. I think adding conditional statement in |
take |
Possibly related to |
We might need to restrict this optimization to infallible casts, such as when the cast target type is wider than the input expression. |
I think I have found out the main problem here. I added a few debugging statements to print the DataTypes as the Optimizer code is running, here is what I found:
Instead of checking if the value held by I further verified this by running a command where the right-hand side value is incompatible with the target datatype, and I got this:
Since Same for
|
Describe the bug
I found that
UnwrapCastInComparison
always assumes the cast operation can succeed, but when it cannot, it results in incorrect optimization results.To Reproduce
Run query in CLI (compiled from the latest main: f775791)
Expected behavior
When optimizations are disabled, the above queries will produce different results, which are correct.
Additional context
I don't think this is a very urgent bug because both Spark and DuckDB have similar issues.
The text was updated successfully, but these errors were encountered: