-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat](case when) join extract or expression from case when / if / nullif expression #58430
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
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
620375c to
ec4225c
Compare
|
run buildall |
ec4225c to
cdcdf48
Compare
|
run buildall |
cdcdf48 to
e0360b8
Compare
|
run buildall |
1 similar comment
|
run buildall |
TPC-H: Total hot run time: 34179 ms |
TPC-DS: Total hot run time: 184153 ms |
ClickBench: Total hot run time: 27.36 s |
FE Regression Coverage ReportIncrement line coverage |
|
run buildall |
TPC-H: Total hot run time: 34437 ms |
TPC-DS: Total hot run time: 184194 ms |
ClickBench: Total hot run time: 27.46 s |
FE UT Coverage ReportIncrement line coverage |
61bc61e to
7bcf8ec
Compare
|
run buildall |
9e80c6a to
d98053f
Compare
|
run buildall |
TPC-H: Total hot run time: 34397 ms |
TPC-DS: Total hot run time: 185628 ms |
ClickBench: Total hot run time: 27.42 s |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
4ee3dc5 to
88c442b
Compare
|
run buildall |
|
PR approved by at least one committer and no changes requested. |
TPC-H: Total hot run time: 34015 ms |
TPC-DS: Total hot run time: 181988 ms |
ClickBench: Total hot run time: 27.48 s |
FE UT Coverage ReportIncrement line coverage |
|
run external |
…llif expression (apache#58430) Join extract OR expressions from case when expression. 1. extract conditions for one side, latter can push down the one side condition: ``` t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b) + t2.b + t2.c > 10) => t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b end) + t2.b + t2.c > 10) AND (not (t2.a + t2.b + t2.c > 10) or not (t2.b + t2.b + t2.c > 10)) ``` 2. extract condition for both sides, which use for OR EXPANSION rule: the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition. ``` t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b => t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b AND (t2.a = t1.a + t1.b or t2.b = t1.a + t1.b) ``` Notice We don't extract more than one case when like expressions. because it may generate expressions with combinatorial explosion. for example: ``` (((case c1 then p1 else p2 end) + (case when d1 then q1 else q2 end))) + a > 10 => (p1 + q1 + a > 10) or (p1 + q2 + a > 10) or (p2 + q1 + a > 10) or (p2 + q2 + a > 10) ``` so we only extract at most one case when like expression for each condition.
…llif expression (apache#58430) Join extract OR expressions from case when expression. 1. extract conditions for one side, latter can push down the one side condition: ``` t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b) + t2.b + t2.c > 10) => t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b end) + t2.b + t2.c > 10) AND (not (t2.a + t2.b + t2.c > 10) or not (t2.b + t2.b + t2.c > 10)) ``` 2. extract condition for both sides, which use for OR EXPANSION rule: the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition. ``` t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b => t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b AND (t2.a = t1.a + t1.b or t2.b = t1.a + t1.b) ``` Notice We don't extract more than one case when like expressions. because it may generate expressions with combinatorial explosion. for example: ``` (((case c1 then p1 else p2 end) + (case when d1 then q1 else q2 end))) + a > 10 => (p1 + q1 + a > 10) or (p1 + q2 + a > 10) or (p2 + q1 + a > 10) or (p2 + q2 + a > 10) ``` so we only extract at most one case when like expression for each condition.
…llif expression (apache#58430) Join extract OR expressions from case when expression. 1. extract conditions for one side, latter can push down the one side condition: ``` t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b) + t2.b + t2.c > 10) => t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b end) + t2.b + t2.c > 10) AND (not (t2.a + t2.b + t2.c > 10) or not (t2.b + t2.b + t2.c > 10)) ``` 2. extract condition for both sides, which use for OR EXPANSION rule: the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition. ``` t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b => t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b AND (t2.a = t1.a + t1.b or t2.b = t1.a + t1.b) ``` Notice We don't extract more than one case when like expressions. because it may generate expressions with combinatorial explosion. for example: ``` (((case c1 then p1 else p2 end) + (case when d1 then q1 else q2 end))) + a > 10 => (p1 + q1 + a > 10) or (p1 + q2 + a > 10) or (p2 + q1 + a > 10) or (p2 + q2 + a > 10) ``` so we only extract at most one case when like expression for each condition.
…llif expression (apache#58430) Join extract OR expressions from case when expression. 1. extract conditions for one side, latter can push down the one side condition: ``` t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b) + t2.b + t2.c > 10) => t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b end) + t2.b + t2.c > 10) AND (not (t2.a + t2.b + t2.c > 10) or not (t2.b + t2.b + t2.c > 10)) ``` 2. extract condition for both sides, which use for OR EXPANSION rule: the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition. ``` t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b => t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b AND (t2.a = t1.a + t1.b or t2.b = t1.a + t1.b) ``` Notice We don't extract more than one case when like expressions. because it may generate expressions with combinatorial explosion. for example: ``` (((case c1 then p1 else p2 end) + (case when d1 then q1 else q2 end))) + a > 10 => (p1 + q1 + a > 10) or (p1 + q2 + a > 10) or (p2 + q1 + a > 10) or (p2 + q2 + a > 10) ``` so we only extract at most one case when like expression for each condition.
…llif expression (apache#58430) Join extract OR expressions from case when expression. 1. extract conditions for one side, latter can push down the one side condition: ``` t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b) + t2.b + t2.c > 10) => t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b end) + t2.b + t2.c > 10) AND (not (t2.a + t2.b + t2.c > 10) or not (t2.b + t2.b + t2.c > 10)) ``` 2. extract condition for both sides, which use for OR EXPANSION rule: the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition. ``` t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b => t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b AND (t2.a = t1.a + t1.b or t2.b = t1.a + t1.b) ``` Notice We don't extract more than one case when like expressions. because it may generate expressions with combinatorial explosion. for example: ``` (((case c1 then p1 else p2 end) + (case when d1 then q1 else q2 end))) + a > 10 => (p1 + q1 + a > 10) or (p1 + q2 + a > 10) or (p2 + q1 + a > 10) or (p2 + q2 + a > 10) ``` so we only extract at most one case when like expression for each condition.
…llif expression (apache#58430) Join extract OR expressions from case when expression. 1. extract conditions for one side, latter can push down the one side condition: ``` t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b) + t2.b + t2.c > 10) => t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b end) + t2.b + t2.c > 10) AND (not (t2.a + t2.b + t2.c > 10) or not (t2.b + t2.b + t2.c > 10)) ``` 2. extract condition for both sides, which use for OR EXPANSION rule: the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition. ``` t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b => t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b AND (t2.a = t1.a + t1.b or t2.b = t1.a + t1.b) ``` Notice We don't extract more than one case when like expressions. because it may generate expressions with combinatorial explosion. for example: ``` (((case c1 then p1 else p2 end) + (case when d1 then q1 else q2 end))) + a > 10 => (p1 + q1 + a > 10) or (p1 + q2 + a > 10) or (p2 + q1 + a > 10) or (p2 + q2 + a > 10) ``` so we only extract at most one case when like expression for each condition.
…llif expression (apache#58430) Join extract OR expressions from case when expression. 1. extract conditions for one side, latter can push down the one side condition: ``` t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b) + t2.b + t2.c > 10) => t1 join t2 on not (case when t1.a = 1 then t2.a else t2.b end) + t2.b + t2.c > 10) AND (not (t2.a + t2.b + t2.c > 10) or not (t2.b + t2.b + t2.c > 10)) ``` 2. extract condition for both sides, which use for OR EXPANSION rule: the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition. ``` t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b => t1 join t2 on (case when t1.a = 1 then t2.a else t2.b end) = t1.a + t1.b AND (t2.a = t1.a + t1.b or t2.b = t1.a + t1.b) ``` Notice We don't extract more than one case when like expressions. because it may generate expressions with combinatorial explosion. for example: ``` (((case c1 then p1 else p2 end) + (case when d1 then q1 else q2 end))) + a > 10 => (p1 + q1 + a > 10) or (p1 + q2 + a > 10) or (p2 + q1 + a > 10) or (p2 + q2 + a > 10) ``` so we only extract at most one case when like expression for each condition.
What problem does this PR solve?
Join extract OR expressions from case when expression.
extract condition for both sides, which use for OR EXPANSION rule:
the OR EXPANSION condition is an OR expression and all its disjuncts are all hash condition.
Notice We don't extract more than one case when like expressions.
because it may generate expressions with combinatorial explosion.
for example:
so we only extract at most one case when like expression for each condition.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)