silundong commented on code in PR #4678:
URL: https://github.com/apache/calcite/pull/4678#discussion_r2610186506
##########
core/src/test/resources/sql/planner.iq:
##########
@@ -215,14 +215,13 @@ select a from (values (1.0), (4.0), (null)) as t3 (a);
!ok
EnumerableAggregate(group=[{0}])
- EnumerableNestedLoopJoin(condition=[IS NOT DISTINCT FROM($0, $1)],
joinType=[semi])
+ EnumerableHashJoin(condition=[IS NOT DISTINCT FROM($0, $1)], joinType=[semi])
EnumerableCalc(expr#0=[{inputs}], expr#1=[CAST($t0):DECIMAL(11, 1)],
A=[$t1])
- EnumerableAggregate(group=[{0}])
- EnumerableNestedLoopJoin(condition=[IS NOT DISTINCT FROM($0, $1)],
joinType=[semi])
- EnumerableCalc(expr#0=[{inputs}], expr#1=[CAST($t0):DECIMAL(11, 1)
NOT NULL], A=[$t1])
- EnumerableValues(tuples=[[{ 1.0 }, { 2.0 }, { 3.0 }, { 4.0 }, {
5.0 }]])
- EnumerableCalc(expr#0=[{inputs}], expr#1=[CAST($t0):DECIMAL(11, 1)
NOT NULL], A=[$t1])
- EnumerableValues(tuples=[[{ 1 }, { 2 }]])
+ EnumerableHashJoin(condition=[IS NOT DISTINCT FROM($0, $1)],
joinType=[semi])
Review Comment:
During the optimization in Volcano, UnionMergeRule merges two Intersects
into one Intersect (three inputs). The two candidate plans are then applied to
IntersectToSemiJoinRule, resulting in:
```
// plan 1 -- two Intersect are respectively applied to the
IntersectToSemiJoinRule
Agg
Join(condition=IS NOT DISTINCT FROM)
Agg
Join(condition=IS NOT DISTINCT FROM)
Input2
Input3
Input1
// plan 2 -- one Intersect with three inputs is applied to
IntersectToSemiJoinRule
Agg
Join(condition=IS NOT DISTINCT FROM)
Join(condition=IS NOT DISTINCT FROM)
Input2
Input3
Input1
```
before this commit, all the joins above were NLJoin, with plan 1 having a
lower cost;
after this commit, all the joins above are HashJoin, with plan 2 having a
lower cost.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]