[enhancement](Nereids): optimize GroupExpressionMatching (#26196)

This commit is contained in:
jakevin
2023-11-01 19:05:08 +08:00
committed by GitHub
parent 502f5778f4
commit 6010be88bd
10 changed files with 76 additions and 63 deletions

View File

@ -42,10 +42,10 @@ import org.junit.jupiter.api.Test;
import java.util.Iterator;
public class GroupExpressionMatchingTest {
class GroupExpressionMatchingTest {
@Test
public void testLeafNode() {
void testLeafNode() {
Pattern pattern = new Pattern<>(PlanType.LOGICAL_UNBOUND_RELATION);
Memo memo = new Memo(null, new UnboundRelation(StatementScopeIdGenerator.newRelationId(), Lists.newArrayList("test")));
@ -61,7 +61,7 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testDepth2() {
void testDepth2() {
Pattern pattern = new Pattern<>(PlanType.LOGICAL_PROJECT,
new Pattern<>(PlanType.LOGICAL_UNBOUND_RELATION));
@ -93,7 +93,7 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testDepth2WithGroup() {
void testDepth2WithGroup() {
Pattern pattern = new Pattern<>(PlanType.LOGICAL_PROJECT, Pattern.GROUP);
Plan leaf = new UnboundRelation(StatementScopeIdGenerator.newRelationId(), Lists.newArrayList("test"));
@ -119,7 +119,7 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testLeafAny() {
void testLeafAny() {
Pattern pattern = Pattern.ANY;
Memo memo = new Memo(null, new UnboundRelation(StatementScopeIdGenerator.newRelationId(), Lists.newArrayList("test")));
@ -135,7 +135,7 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testAnyWithChild() {
void testAnyWithChild() {
Plan root = new LogicalProject(
ImmutableList.of(new SlotReference("name", StringType.INSTANCE, true,
ImmutableList.of("test"))),
@ -159,7 +159,7 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testInnerLogicalJoinMatch() {
void testInnerLogicalJoinMatch() {
Plan root = new LogicalJoin(JoinType.INNER_JOIN,
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("a")),
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("b"))
@ -181,7 +181,7 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testInnerLogicalJoinMismatch() {
void testInnerLogicalJoinMismatch() {
Plan root = new LogicalJoin(JoinType.LEFT_OUTER_JOIN,
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("a")),
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("b"))
@ -198,7 +198,7 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testTopMatchButChildrenNotMatch() {
void testTopMatchButChildrenNotMatch() {
Plan root = new LogicalJoin(JoinType.LEFT_OUTER_JOIN,
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("a")),
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("b"))
@ -216,12 +216,12 @@ public class GroupExpressionMatchingTest {
}
@Test
public void testSubTreeMatch() {
void testSubTreeMatch() {
Plan root =
new LogicalFilter(ImmutableSet.of(new EqualTo(new UnboundSlot(Lists.newArrayList("a", "id")),
new LogicalFilter<>(ImmutableSet.of(new EqualTo(new UnboundSlot(Lists.newArrayList("a", "id")),
new UnboundSlot(Lists.newArrayList("b", "id")))),
new LogicalJoin(JoinType.INNER_JOIN,
new LogicalJoin(JoinType.LEFT_OUTER_JOIN,
new LogicalJoin<>(JoinType.INNER_JOIN,
new LogicalJoin<>(JoinType.LEFT_OUTER_JOIN,
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("a")),
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("b"))),
new UnboundRelation(StatementScopeIdGenerator.newRelationId(), ImmutableList.of("c")))