[feature](join) support ASOF join#59591
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
6dc9ac9 to
19a3cbf
Compare
|
run buildall |
TPC-H: Total hot run time: 31804 ms |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-DS: Total hot run time: 172506 ms |
ClickBench: Total hot run time: 27.35 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
FE UT Coverage ReportIncrement line coverage |
d8e6c99 to
81a3daa
Compare
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 32078 ms |
TPC-DS: Total hot run time: 173320 ms |
ClickBench: Total hot run time: 26.93 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
TPC-H: Total hot run time: 32282 ms |
TPC-DS: Total hot run time: 174282 ms |
ClickBench: Total hot run time: 27.94 s |
FE Regression Coverage ReportIncrement line coverage |
b5eec36 to
c3f5cab
Compare
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
| ARRAY: 'ARRAY'; | ||
| AS: 'AS'; | ||
| ASC: 'ASC'; | ||
| ASOF: 'ASOF'; |
There was a problem hiding this comment.
add new keywords into non-reserved keywords list
| ASOF_LEFT_INNER_JOIN("ASOF_LEFT_INNER_JOIN", TJoinOp.ASOF_LEFT_INNER_JOIN), | ||
| ASOF_RIGHT_INNER_JOIN("ASOF_RIGHT_INNER_JOIN", TJoinOp.ASOF_RIGHT_INNER_JOIN), | ||
| ASOF_LEFT_OUTER_JOIN("ASOF_LEFT_OUTER_JOIN", TJoinOp.ASOF_LEFT_OUTER_JOIN), | ||
| ASOF_RIGHT_OUTER_JOIN("ASOF_LEFT_INNER_JOIN", TJoinOp.ASOF_RIGHT_OUTER_JOIN); |
There was a problem hiding this comment.
| ASOF_RIGHT_OUTER_JOIN("ASOF_LEFT_INNER_JOIN", TJoinOp.ASOF_RIGHT_OUTER_JOIN); | |
| ASOF_RIGHT_OUTER_JOIN("ASOF_LEFT_OUTER_JOIN", TJoinOp.ASOF_RIGHT_OUTER_JOIN); |
| if (!(matchCondition instanceof LessThan | ||
| || matchCondition instanceof LessThanEqual | ||
| || matchCondition instanceof GreaterThan | ||
| || matchCondition instanceof GreaterThanEqual)) { | ||
| throw new ParseException("ASOF JOIN's MATCH_CONDITION must be <, <=, >, >=", join); | ||
| } |
There was a problem hiding this comment.
It's better to enforce the restriction directly in the parser, as it can speed up parsing.
| if (expression.child(0).isConstant() || expression.child(1).isConstant()) { | ||
| throw new ParseException("ASOF JOIN's EQUAL conjunct's children must not be constant"); | ||
| } |
There was a problem hiding this comment.
why check it here? could we reject all constant expression here?
| return new LogicalJoin<>( | ||
| using.getJoinType(), | ||
| hashEqExprs.build(), ImmutableList.of(using.getMatchCondition().get()), | ||
| using.getDistributeHint(), Optional.empty(), rightConjunctsSlots, | ||
| using.children(), null); | ||
| } else { | ||
| return new LogicalJoin<>( | ||
| using.getJoinType() == JoinType.CROSS_JOIN ? JoinType.INNER_JOIN : using.getJoinType(), | ||
| hashEqExprs.build(), ImmutableList.of(), | ||
| using.getDistributeHint(), Optional.empty(), rightConjunctsSlots, | ||
| using.children(), null); |
There was a problem hiding this comment.
| return new LogicalJoin<>( | |
| using.getJoinType(), | |
| hashEqExprs.build(), ImmutableList.of(using.getMatchCondition().get()), | |
| using.getDistributeHint(), Optional.empty(), rightConjunctsSlots, | |
| using.children(), null); | |
| } else { | |
| return new LogicalJoin<>( | |
| using.getJoinType() == JoinType.CROSS_JOIN ? JoinType.INNER_JOIN : using.getJoinType(), | |
| hashEqExprs.build(), ImmutableList.of(), | |
| using.getDistributeHint(), Optional.empty(), rightConjunctsSlots, | |
| using.children(), null); | |
| return new LogicalJoin<>( | |
| using.getJoinType() == JoinType.CROSS_JOIN ? JoinType.INNER_JOIN : using.getJoinType(), | |
| hashEqExprs.build(), using.getMatchCondition().map(ImmutableList::of).orElse(ImmutableList.of()), | |
| using.getDistributeHint(), Optional.empty(), rightConjunctsSlots, | |
| using.children(), null); |
| Pair.of(JoinType.ASOF_LEFT_OUTER_JOIN, JoinType.ASOF_LEFT_OUTER_JOIN), | ||
| Pair.of(JoinType.LEFT_OUTER_JOIN, JoinType.LEFT_OUTER_JOIN)); |
There was a problem hiding this comment.
why not have LEFT_OUTER_JOIN -> ASOF_LEFT_OUTER_JOIN and ASOF_LEFT_OUTER_JOIN -> LEFT_OUTER_JOIN
| .put(Pair.of(JoinType.RIGHT_SEMI_JOIN, JoinType.INNER_JOIN), Pair.of(false, false)) | ||
| .put(Pair.of(JoinType.RIGHT_SEMI_JOIN, JoinType.ASOF_LEFT_INNER_JOIN), Pair.of(false, false)) | ||
| .put(Pair.of(JoinType.RIGHT_SEMI_JOIN, JoinType.ASOF_RIGHT_INNER_JOIN), Pair.of(false, false)) | ||
| .put(Pair.of(JoinType.INNER_JOIN, JoinType.LEFT_OUTER_JOIN), Pair.of(false, true)) |
There was a problem hiding this comment.
why not include INNER_JOIN -> ASOF_LEFT_OUTER_JOIN? and INNER_JOIN -> ASOF_RIGHT_OUTER_JOIN?
| } | ||
| } | ||
|
|
||
| private static Statistics estimateAsofInnerJoin(Statistics leftStats, Statistics rightStats, |
There was a problem hiding this comment.
add ut for new estimation
…and support MATCH_CONDITION commutation
…fix NULL handling - Materialize both sides of MATCH_CONDITION by executing expressions, enabling support for complex expressions (e.g., DATE_ADD) in addition to simple slot references - Fix NULL value handling: NULL comparisons now correctly return no match instead of incorrectly matching rows - Simplify comparison logic by leveraging FE's guarantee that MATCH_CONDITION left side references probe table and right side references build table after
|
run buildall |
Cloud UT Coverage ReportIncrement line coverage Increment coverage report
|
FE UT Coverage ReportIncrement line coverage |
TPC-H: Total hot run time: 30670 ms |
ClickBench: Total hot run time: 29.04 s |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
FE Regression Coverage ReportIncrement line coverage |
What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)