[fix](nereids) fix simplify compare predicate cause by loss precision or cast null#55884
Merged
morrySnow merged 8 commits intoapache:masterfrom Sep 16, 2025
Merged
[fix](nereids) fix simplify compare predicate cause by loss precision or cast null#55884morrySnow merged 8 commits intoapache:masterfrom
morrySnow merged 8 commits intoapache:masterfrom
Conversation
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
Author
|
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 |
Contributor
FE UT Coverage ReportIncrement line coverage |
morrySnow
reviewed
Sep 10, 2025
Comment on lines
604
to
608
Contributor
Author
There was a problem hiding this comment.
have add float test
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
Author
|
run buildall |
Contributor
Author
|
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 |
Contributor
Author
|
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 |
Contributor
FE Regression Coverage ReportIncrement line coverage |
Contributor
Author
|
run buildall |
ClickBench: Total hot run time: 29.61 s |
Contributor
FE Regression Coverage ReportIncrement line coverage |
starocean999
approved these changes
Sep 16, 2025
Contributor
|
PR approved by at least one committer and no changes requested. |
Contributor
|
PR approved by anyone and no changes requested. |
morrySnow
approved these changes
Sep 16, 2025
This was referenced Sep 16, 2025
Closed
Hastyshell
pushed a commit
to Hastyshell/doris
that referenced
this pull request
Nov 12, 2025
…ate cause by loss precision or cast null apache#55884 (apache#4826) ## Proposed changes cherry-pick: apache#55884
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)