-
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
fix: find the right wider decimal datatype for comparison operation #2241
fix: find the right wider decimal datatype for comparison operation #2241
Conversation
3d2b41c
to
acc768f
Compare
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.
Thanks @liukun4515
(DataType::Decimal(p1, s1), DataType::Decimal(p2, s2)) => { | ||
// max(s1, s2) + max(p1-s1, p2-s2), max(s1, s2) | ||
let s = *s1.max(s2); | ||
let range = (p1 - s1).max(p2 - s2); |
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.
👍 I see that the precision includes the scale 👍
DataType::Decimal(38, 10), | ||
DataType::Decimal(25, 8), |
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.
👍
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.
This is inspired by your comments #2200 (comment)
Thanks
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Which issue does this PR close?
Closes #2232
For decimal with the comparison operation, we use the error algorithm to calculate the precision/scale.
Before: max(p1,p2),max(s1,s2)
Now: max(38,max(s1, s2) + max(p1-s1, p2-s2)), max(s1, s2, 38)
Rationale for this change
What changes are included in this PR?
schema
Before this fix, we got the plan #2200 (comment)
After this fix, we got the right converted type in the filter expr
Are there any user-facing changes?
cc @alamb