-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](nereids) fix range inference generate an empty range (#47434)
for `a >= 8 and a <8` will generate a range(a>=8) interset range(a <8) = range[8, 8), this is a empty range. PR #46303 introduce a RangeSet to hold the union of RangeValues, for a empty range[8, 8), RangeSet.asRanges() will return empty. Then cause a index out of bound exception. ``` Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?] at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?] at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?] at java.util.Objects.checkIndex(Objects.java:359) ~[?:?] at java.util.ArrayList.get(ArrayList.java:427) ~[?:?] at org.apache.doris.nereids.rules.expression.rules.RangeInference.simplify(RangeInference.java:166) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.nereids.rules.expression.rules.RangeInference.visitOr(RangeInference.java:130) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.nereids.rules.expression.rules.RangeInference.visitOr(RangeInference.java:59) ~[doris-fe.jar:1.2-SNAPSHOT] ``` Fix: for a empty RangeValue like [8, 8), replace it with an EmptyValue. What's more, this PR will also replace singleton RangeValue like ([8, 8]) to DiscreteValue([8]), so after this PR, simplify range will rewrite `a >= 8 and a <= 8` to `a = 8`. This is just BetweenToEqual rule do. After this PR, we can remove rule BetweenToEqual.
- Loading branch information
Showing
4 changed files
with
30 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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