-
Notifications
You must be signed in to change notification settings - Fork 28
feat: support left-outer and left-mark hash join impl rules #274
base: main
Are you sure you want to change the base?
Conversation
Not ideal, wants to unite inner, left-outer, and left-mark into one rule Signed-off-by: Yuchen Liang <[email protected]>
Signed-off-by: Yuchen Liang <[email protected]>
Signed-off-by: Yuchen Liang <[email protected]>
This reverts commit 973e80c.
Signed-off-by: Yuchen Liang <[email protected]>
…achable!` Signed-off-by: Yuchen Liang <[email protected]>
tpch Q13 needs a rule to push split a filter from the join node, and then the join could be turned into a left-outer hash join. Working on this now. ... ├── cond:And │ ├── Eq │ │ ├── #0 │ │ └── #9 │ └── Like { expr: #16, pattern: "%special%requests%", negated: true, case_insensitive: false } |
Signed-off-by: Yuchen Liang <[email protected]>
We eliminate another nested loop join in TPC-H Q13 Signed-off-by: Yuchen Liang <[email protected]>
Signed-off-by: Yuchen Liang <[email protected]>
Signed-off-by: Yuchen Liang <[email protected]>
├── PhysicalScan { table: customer } | ||
└── PhysicalScan { table: orders } | ||
└── PhysicalFilter { cond: Like { expr: #8, pattern: "%special%requests%", negated: true, case_insensitive: false } } |
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.
pushing down the filter and turn into hash join.
├── cond:Eq | ||
│ ├── #1 | ||
│ └── #14 | ||
└── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #1 ], right_keys: [ #0 ] } |
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.
picked up by the new hash-join-left-mark rule
│ └── PhysicalScan { table: part } | ||
└── PhysicalScan { table: lineitem } | ||
└── PhysicalProjection { exprs: [ #0, #2 ] } | ||
└── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ] } |
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.
left-outer hash join
│ └── Eq | ||
│ ├── #0 | ||
│ └── #1 | ||
└── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ] } |
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.
left-outer hash join
├── cond:Eq | ||
│ ├── #0 | ||
│ └── #11 | ||
└── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #0 ], right_keys: [ #0 ] } |
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.
left-mark hash join
└── PhysicalNestedLoopJoin | ||
├── join_type: Inner | ||
├── cond:And | ||
│ ├── Gt | ||
│ │ ├── Cast { cast_to: Float64, child: #2 } | ||
│ │ └── #8 | ||
│ ├── Eq | ||
│ │ ├── #0 | ||
│ │ └── #6 | ||
│ └── Eq | ||
│ ├── #1 | ||
│ └── #7 | ||
├── PhysicalFilter { cond: #5 } |
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.
This one is a little confusing. investigating ...
Signed-off-by: Yuchen Liang <[email protected]>
(Join(JoinType::Inner), child_a, child_b) | ||
); | ||
|
||
define_rule!( |
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 don't think this rule is correct. You cannot move the outer join condition into a filter in some cases.
Consider select * from a left join b on a.x = b.y and b.z = 1
. The result is different from select * from a left join b on a.x = b.y where b.z = 1
. Assume left table is x=1, right table is y=1,z=2, the correct result is 1, NULL, NULL, versus the rule will produce zero rows.
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.
ahh, I realized that this is a filter pushdown, then it might be correct; I will do a review later :)
Problem
We should be able to convert left-outer join and left-mark logical equi join to hash join.
Summary of changes
misc
simplify_log_expr
to stop usingunreachable!