|
28 | 28 | import org.apache.doris.nereids.trees.expressions.Cast; |
29 | 29 | import org.apache.doris.nereids.trees.expressions.EqualTo; |
30 | 30 | import org.apache.doris.nereids.trees.expressions.Expression; |
| 31 | +import org.apache.doris.nereids.trees.expressions.GreaterThan; |
31 | 32 | import org.apache.doris.nereids.trees.expressions.IsNull; |
32 | 33 | import org.apache.doris.nereids.trees.expressions.MatchAny; |
33 | 34 | import org.apache.doris.nereids.trees.expressions.NamedExpression; |
@@ -434,6 +435,33 @@ void testLogicalJoin() { |
434 | 435 | Assertions.assertEquals(expectOtherConjuncts1, rewrittenJoin1.getOtherJoinConjuncts()); |
435 | 436 | } |
436 | 437 |
|
| 438 | + @Test |
| 439 | + void testAsofJoinDisableConstantPropagation() { |
| 440 | + Set<Expression> conjunctions1 = ImmutableSet.of( |
| 441 | + new EqualTo(studentId, new IntegerLiteral(1)) |
| 442 | + ); |
| 443 | + Set<Expression> conjunctions2 = ImmutableSet.of( |
| 444 | + new EqualTo(scoreCid, new IntegerLiteral(2)) |
| 445 | + ); |
| 446 | + LogicalFilter left = new LogicalFilter<>(conjunctions1, student); |
| 447 | + LogicalFilter right = new LogicalFilter<>(conjunctions2, score); |
| 448 | + |
| 449 | + List<Expression> hashConjuncts = ImmutableList.of( |
| 450 | + new EqualTo(studentId, scoreSid) |
| 451 | + ); |
| 452 | + List<Expression> otherConjuncts = ImmutableList.of( |
| 453 | + new GreaterThan(studentId, studentAge) |
| 454 | + ); |
| 455 | + |
| 456 | + LogicalJoin asofJoin = new LogicalJoin<>(JoinType.ASOF_LEFT_INNER_JOIN, hashConjuncts, otherConjuncts, left, right, null); |
| 457 | + LogicalJoin rewrittenAsofJoin = (LogicalJoin) executor.rewriteRoot(asofJoin, jobContext); |
| 458 | + |
| 459 | + // For ASOF join, constant propagation should be disabled and no rewrite should happen. |
| 460 | + Assertions.assertEquals(JoinType.ASOF_LEFT_INNER_JOIN, rewrittenAsofJoin.getJoinType()); |
| 461 | + Assertions.assertEquals(hashConjuncts, rewrittenAsofJoin.getHashJoinConjuncts()); |
| 462 | + Assertions.assertEquals(otherConjuncts, rewrittenAsofJoin.getOtherJoinConjuncts()); |
| 463 | + } |
| 464 | + |
437 | 465 | private void assertRewrite(String expression, String expected) { |
438 | 466 | assertRewrite(expression, expected, true); |
439 | 467 | } |
|
0 commit comments