-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat](simplify range) Add more range inference simplifier rule. #59818
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
[feat](simplify range) Add more range inference simplifier rule. #59818
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
a2839af to
72d4dea
Compare
|
run buildall |
TPC-H: Total hot run time: 32104 ms |
TPC-DS: Total hot run time: 172879 ms |
FE Regression Coverage ReportIncrement line coverage |
72d4dea to
492f6d9
Compare
|
run buildall |
TPC-H: Total hot run time: 31656 ms |
TPC-DS: Total hot run time: 172157 ms |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
|
run external |
|
run buildall |
TPC-H: Total hot run time: 31283 ms |
TPC-DS: Total hot run time: 173564 ms |
ClickBench: Total hot run time: 26.85 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. |
|
run external |
…che#59818) Add more inference rules: 1. simplify: `IsNull AND xx` ``` TA is null and TA > 10 => TA is null and null TA is null and TA = 10 => TA is null and null TA is null and TA != 10 => TA is null and null ``` then if this expression is in where condition, it will replace null to FALSE, and fold this expression to FALSE 2. simplify: `IsNotNull OR xx` ``` TA is not null or TA > 10 => TA is not null or null TA is not null or TA = 10 => TA is not null or null TA is not null or TA != 10 => TA is not null or null ``` then if this expression is in where condition, it will replace null to FALSE, and fold this expression to TA is not null 3. simplify: IsNotNull(TA) AND RangeAll(TA) = IsNotNull(TA) ``` TA is not null and (TA is not null or null) => TA is not null ``` 4. simplify: IsNull(TA) AND RangeAll(TA) = EmptyValue(TA) ``` TA is null and (TA is not null or null) = TA is null and null ``` 5. simplify: IsNotNull(TA) or EmptyValue(TA) = RangeAll(TA) ``` TA is not null or (TA is null and null) = TA is not null or null ``` 6. Fix merge compound value bug if `A AND B` is FALSE/EmptyValue, A AND (B OR C) = A AND C. but this has bug, if 'A AND B' is FALSE, the equation is correct. but if 'A AND B' is EmptyValue and A nullable, the equation maybe still wrong, for example: `a > 100 and (a = 1 or a is not null)`, it cann't simplify to `a > 100 and a is not null`. so we give up simplify this expression just in one step, if `A and B` is empty value, we replace B with EmptyValue, then we will have `A AND (B OR C)` = `A AND (EmptyValue OR C)`, then in the next expression rewrite iteration, it will try to simplify `EmptyValue OR C`. for the same logical for OR, then for 'A OR (B AND C)', if A OR B is RangeAll, then we replace B with RangeAll.
Add more inference rules:
IsNull AND xxthen if this expression is in where condition, it will replace null to FALSE, and fold this expression to FALSE
IsNotNull OR xxthen if this expression is in where condition, it will replace null to FALSE, and fold this expression to TA is not null
if
A AND Bis FALSE/EmptyValue, A AND (B OR C) = A AND C.but this has bug, if 'A AND B' is FALSE, the equation is correct.
but if 'A AND B' is EmptyValue and A nullable, the equation maybe still wrong, for example:
a > 100 and (a = 1 or a is not null), it cann't simplify toa > 100 and a is not null.so we give up simplify this expression just in one step, if
A and Bis empty value, we replace B with EmptyValue, then we will haveA AND (B OR C)=A AND (EmptyValue OR C), then in the next expression rewrite iteration, it will try to simplifyEmptyValue OR C.for the same logical for OR, then for 'A OR (B AND C)', if A OR B is RangeAll, then we replace B with RangeAll.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)