-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat](nereids) opt condition expression in filter / join / if /case when #57025
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](nereids) opt condition expression in filter / join / if /case when #57025
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
7e13974 to
14f64e7
Compare
|
run buildall |
TPC-DS: Total hot run time: 190165 ms |
ClickBench: Total hot run time: 30.6 s |
|
run buildall |
TPC-DS: Total hot run time: 190510 ms |
ClickBench: Total hot run time: 30.45 s |
|
run buildall |
aa203f9 to
0ec20a4
Compare
|
run buildall |
FE Regression Coverage ReportIncrement line coverage |
0ec20a4 to
95ca6c5
Compare
|
run buildall |
TPC-DS: Total hot run time: 188578 ms |
ClickBench: Total hot run time: 30.89 s |
|
run buildall |
|
run buildall |
|
run buildall |
|
run buildall |
TPC-DS: Total hot run time: 190321 ms |
ClickBench: Total hot run time: 31.03 s |
FE UT Coverage ReportIncrement line coverage |
|
run buildall |
ClickBench: Total hot run time: 30.36 s |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
…when (apache#57025) For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition. And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression `null and not(null)` in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF. For a expression `x <=> y` in condition, if one of them is not-nullable, then it can rewrite to `x = y`. Note that if a expression is not a condition, `x <=> y` can rewrite to `x = y` require that both x and y are not-nullable. Here is some example: 1. replace null with false ``` null and (null or null) and not(null) => false and (false or false) and not(null) case when null and not (null) then ... => case when false and not (null) then ... if(null and not(null), ...) => if (false and not(null), ...) ``` 2. replace null safe equal to equal if at least one of its child is non-nullable ``` x <=> 3 and not(x <=> 3) => x = 3 and not(x <=> 3) case when x <=> 3 then ... => case when x = 3 then ... if(x <=> 3, ...) => if(x=3, ...) ``` 3. rewrite if expression in condition if its else branch is true / false literal. suppose the if is in a filter, then will have ``` if(c, p, true) => not(c <=> true) or p if(c, p, false) => c and p ``` Currently, the expression rewrite framework cann't known the expression's plan, In order to indicate that the expression is on the filter / join, we add the expression's plan and source to the ExpressionRewriteContext to indicate the expression's location.
…when (apache#57025) For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition. And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF. For a expression in condition, if one of them is not-nullable, then it can rewrite to . Note that if a expression is not a condition, can rewrite to require that both x and y are not-nullable.
…when (apache#57025) For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition. And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF. For a expression in condition, if one of them is not-nullable, then it can rewrite to . Note that if a expression is not a condition, can rewrite to require that both x and y are not-nullable.
…when (apache#57025) For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition. And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF. For a expression in condition, if one of them is not-nullable, then it can rewrite to . Note that if a expression is not a condition, can rewrite to require that both x and y are not-nullable.
…when (apache#57025) For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition. And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF. For a expression in condition, if one of them is not-nullable, then it can rewrite to . Note that if a expression is not a condition, can rewrite to require that both x and y are not-nullable.
…when (apache#57025) For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition. And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF. For a expression in condition, if one of them is not-nullable, then it can rewrite to . Note that if a expression is not a condition, can rewrite to require that both x and y are not-nullable.
…when (apache#57025) For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition. And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF. For a expression in condition, if one of them is not-nullable, then it can rewrite to . Note that if a expression is not a condition, can rewrite to require that both x and y are not-nullable.
For a condition expression, replace null to false, null safe equal to equal. The condition include filter condition, join condition, if condition, case when condition.
And for the condition expression, only replace those sub expression which its ancestors to the condition root are all AND / OR / CASE WHEN / IF. So, for a expression
null and not(null)in a filter, the first null can be replaced, but the second null cann't be replaced because its parent is NOT, not in AND / OR / CASE WHEN / IF.For a expression
x <=> yin condition, if one of them is not-nullable, then it can rewrite tox = y. Note that if a expression is not a condition,x <=> ycan rewrite tox = yrequire that both x and y are not-nullable.Here is some example:
suppose the if is in a filter, then will have
Currently, the expression rewrite framework cann't known the expression's plan, In order to indicate that the expression is on the filter / join, we add the expression's plan and source to the ExpressionRewriteContext to indicate the expression's location.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)