-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat](case when) replace nested inner case when duplicate condition to true/false #56469
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](case when) replace nested inner case when duplicate condition to true/false #56469
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
3fa3969 to
77aefc8
Compare
|
run buildall |
77aefc8 to
e3f49ae
Compare
|
run buildall |
ClickBench: Total hot run time: 30.04 s |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
ClickBench: Total hot run time: 30.04 s |
FE Regression Coverage ReportIncrement line coverage |
|
run p0 |
|
run feut |
FE Regression Coverage ReportIncrement line coverage |
| Expression typeCoercionThen = TypeCoercionUtils.ensureSameResultType( | ||
| originCaseWhen, whenClause.getResult(), context); |
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.
why need to call ensureSameResultType? after analysis, all when clause's result and defualt value should be same type
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.
update
| // a) when enter a case/if branch, set this condition to TRUE literal | ||
| // b) when leave a case/if branch, set this condition to FALSE literal | ||
| // c) when leave the whole case/if statement, remove this condition literal | ||
| private final Map<Expression, BooleanLiteral> conditionLiterals = Maps.newHashMap(); |
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.
i think u'd better add a ut to check this map work as u expected under all conditions
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 ut
d95ae1d to
f15a4b8
Compare
|
run buildall |
8696a2a to
9298b5e
Compare
|
run buildall |
097dfe5 to
0f8ad80
Compare
|
run buildall |
|
run buildall |
|
run buildall |
ClickBench: Total hot run time: 30.74 s |
|
run buildall |
TPC-DS: Total hot run time: 190424 ms |
ClickBench: Total hot run time: 30.74 s |
FE UT Coverage ReportIncrement line coverage |
FE Regression Coverage ReportIncrement line coverage |
|
run p0 |
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. |
…to true/false (apache#56469) for nested case when, replace the inner case duplicate condition to true/false when this condition also exists in outer case condition: 1. if it exists in outer case's current branch condition, replace it with TRUE: case when A then (case when A and B then 1 else 2 end) ... end then inner case condition A will replace with TRUE: case when A then (case when TRUE and B then 1 else 2 end) ... end 2. if it exists in outer case's previous branch condition, replace it with FALSE: case when A then C when B then (case when A and D then 1 else 2 end) ... end then inner case condition A will replace with FALSE: case when A then C when B then (case when FALSE and D then 1 else 2 end) ... end this PR also opt fold case when and fold if statement. for case when / if expression, if all their branches values equals, then rewrite them to the same value.
…to true/false (apache#56469) for nested case when, replace the inner case duplicate condition to true/false when this condition also exists in outer case condition: 1. if it exists in outer case's current branch condition, replace it with TRUE: case when A then (case when A and B then 1 else 2 end) ... end then inner case condition A will replace with TRUE: case when A then (case when TRUE and B then 1 else 2 end) ... end 2. if it exists in outer case's previous branch condition, replace it with FALSE: case when A then C when B then (case when A and D then 1 else 2 end) ... end then inner case condition A will replace with FALSE: case when A then C when B then (case when FALSE and D then 1 else 2 end) ... end this PR also opt fold case when and fold if statement. for case when / if expression, if all their branches values equals, then rewrite them to the same value.
…to true/false (apache#56469) for nested case when, replace the inner case duplicate condition to true/false when this condition also exists in outer case condition: 1. if it exists in outer case's current branch condition, replace it with TRUE: case when A then (case when A and B then 1 else 2 end) ... end then inner case condition A will replace with TRUE: case when A then (case when TRUE and B then 1 else 2 end) ... end 2. if it exists in outer case's previous branch condition, replace it with FALSE: case when A then C when B then (case when A and D then 1 else 2 end) ... end then inner case condition A will replace with FALSE: case when A then C when B then (case when FALSE and D then 1 else 2 end) ... end this PR also opt fold case when and fold if statement. for case when / if expression, if all their branches values equals, then rewrite them to the same value.
…to true/false (apache#56469) for nested case when, replace the inner case duplicate condition to true/false when this condition also exists in outer case condition: 1. if it exists in outer case's current branch condition, replace it with TRUE: case when A then (case when A and B then 1 else 2 end) ... end then inner case condition A will replace with TRUE: case when A then (case when TRUE and B then 1 else 2 end) ... end 2. if it exists in outer case's previous branch condition, replace it with FALSE: case when A then C when B then (case when A and D then 1 else 2 end) ... end then inner case condition A will replace with FALSE: case when A then C when B then (case when FALSE and D then 1 else 2 end) ... end this PR also opt fold case when and fold if statement. for case when / if expression, if all their branches values equals, then rewrite them to the same value.
…to true/false (apache#56469) for nested case when, replace the inner case duplicate condition to true/false when this condition also exists in outer case condition: 1. if it exists in outer case's current branch condition, replace it with TRUE: case when A then (case when A and B then 1 else 2 end) ... end then inner case condition A will replace with TRUE: case when A then (case when TRUE and B then 1 else 2 end) ... end 2. if it exists in outer case's previous branch condition, replace it with FALSE: case when A then C when B then (case when A and D then 1 else 2 end) ... end then inner case condition A will replace with FALSE: case when A then C when B then (case when FALSE and D then 1 else 2 end) ... end this PR also opt fold case when and fold if statement. for case when / if expression, if all their branches values equals, then rewrite them to the same value.
…to true/false (apache#56469) for nested case when, replace the inner case duplicate condition to true/false when this condition also exists in outer case condition: 1. if it exists in outer case's current branch condition, replace it with TRUE: case when A then (case when A and B then 1 else 2 end) ... end then inner case condition A will replace with TRUE: case when A then (case when TRUE and B then 1 else 2 end) ... end 2. if it exists in outer case's previous branch condition, replace it with FALSE: case when A then C when B then (case when A and D then 1 else 2 end) ... end then inner case condition A will replace with FALSE: case when A then C when B then (case when FALSE and D then 1 else 2 end) ... end this PR also opt fold case when and fold if statement. for case when / if expression, if all their branches values equals, then rewrite them to the same value.
for nested case when, replace the inner case duplicate condition to true/false when this condition also exists in outer case condition:
then inner case condition A will replace with TRUE:
case when A then C when B then (case when A and D then 1 else 2 end) ... endthen inner case condition A will replace with FALSE:
case when A then C when B then (case when FALSE and D then 1 else 2 end) ... endthis PR also opt fold case when and fold if statement. for case when / if expression, if all their branches values equals, then rewrite them to the same value.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)