-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](nereids) fix simplify compare predicate cause by loss precision or cast null #55884
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
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
TPC-H: Total hot run time: 34682 ms |
TPC-DS: Total hot run time: 188874 ms |
ClickBench: Total hot run time: 30.23 s |
FE UT Coverage ReportIncrement line coverage |
| assertRewrite(new EqualTo(new Cast(bigIntSlot, DoubleType.INSTANCE), new DoubleLiteral(-9007199254740991.0)), | ||
| new EqualTo(bigIntSlot, new BigIntLiteral(-9007199254740991L))); | ||
| assertRewrite(new EqualTo(new Cast(bigIntSlot, DoubleType.INSTANCE), new DoubleLiteral(9007199254740991.0)), | ||
| new EqualTo(bigIntSlot, new BigIntLiteral(9007199254740991L))); | ||
| assertRewrite(new EqualTo(new Cast(bigIntSlot, DoubleType.INSTANCE), new DoubleLiteral(noLossBound)), |
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.
add float test case
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.
have add float test
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
|
run buildall |
TPC-H: Total hot run time: 35001 ms |
TPC-DS: Total hot run time: 189497 ms |
ClickBench: Total hot run time: 29.97 s |
|
run buildall |
TPC-H: Total hot run time: 34800 ms |
TPC-DS: Total hot run time: 188981 ms |
ClickBench: Total hot run time: 29.44 s |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
ClickBench: Total hot run time: 29.61 s |
FE Regression Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
…ate cause by loss precision or cast null apache#55884 (apache#4826) ## Proposed changes cherry-pick: apache#55884
What problem does this PR solve?
simplify compare predicate have bug:
cast(integer as double) cmp doublemay cause error due to int to double may losss precision;for
cast(c_bigint as double) compare double literal, will simplify it toc_bigint compare integer like literal,but notice that, only value between [-2^53 + 1, 2^53 - 1] can integer <=> double conversion be one to one,
for example, for sql
cast(c_bigint as double) = cast('1000000000000000000.0' as double), we can't simplify it toc_bigint = 1000000000000000000because the actual range for c_bigint is [999999999999999936, 1000000000000000064].so we need check the right literal's bound
cast(integer/decimal as decimal) cmp decimal literalmay cause error due to cast may generate null. forcast(slot as decimalX), if the casted slot is integer or decimal, and its range > decimal X's range or its range == decimal X's range and its scale > decimal X's scale, then the cast maybe null, so don't simplify this predicate.for example:
cast(1234 as decimal(6, 3))will evaluate to null,cast(9.99 as decimal(2, 1))will be nullso for sql
cast(col as decimal(4, 1)) < 999.8, if col is int or decimal(5, 0) like type we can't simplify it tocol < 1000because the cast result may be null (example col = -10000)Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)