-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix type coercion between the sides of an UNION #15340
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Needs backporting to 18.0 and 19.0, presumably? Caused by #15192? |
Are there similar issues with group by, or is this just an issue with distinct? |
@systay OK here's a more-or-less working fix for this (which includes several related cleanups, particularly removing evalengine APIs which we don't need anymore). You'll see that some plans have changed: we're not asking for |
Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Vicent Marti <[email protected]>
Signed-off-by: Vicent Marti <[email protected]>
Signed-off-by: Vicent Marti <[email protected]>
4936a31
to
21e4558
Compare
Signed-off-by: Vicent Marti <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #15340 +/- ##
==========================================
- Coverage 65.72% 65.72% -0.01%
==========================================
Files 1563 1562 -1
Lines 194027 193952 -75
==========================================
- Hits 127529 127468 -61
+ Misses 66498 66484 -14 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Vicent Marti <[email protected]>
Fixing this bug was way more involved than we initially expected! The PR is green now and the planner changes have been reviewed with @systay. Basically, we were not properly performing type aggregation nor coercion between the two sides of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title and the description need an update
Updated title and description with an actual list of changes for this PR. ❇️ |
We didn't find any such issues, but you are correct in suspecting This fix solved the issue in the underlying evalengine component, so it should apply to DISTINCT, GROUP BY and ORDER BY. |
@GrahamCampbell ☝️ what @systay said -- sorry I missed your question! The GitHub UI collapsed it. 😅 |
This is not related to those changes and I don't think we need to backport here. |
Aye this is unrelated to any previous issue, and it's not blocking any users or customers afaict. The report was filed by @systay himself and he found the problem by fuzzing. |
Description
For the following SQL query, Vitess doesn't return the same results as MySQL:
Fixing this bug was way more involved than we initially expected! Basically, we were not properly performing type aggregation nor coercion between the two sides of UNION queries. The results for queries like that were only correct when the two sides of the union have the same types (something which is quite common, which is why we hadn't found out yet), but with different types the results are off.
To fix the issue, this PR:
evalengine
, including changing the precision ofDECIMAL
when casting from a decimal with a smaller precision.evalengine.Type
andquerypb.Field
without losing informationUNION
/DISTINCT
engine primitives, so that we're properly aggregating the types between the two sides of the union.Related Issue(s)
Checklist
Deployment Notes