|
|
|
|
@ -23,7 +23,7 @@ import org.apache.doris.nereids.properties.DistributionSpecHash;
|
|
|
|
|
import org.apache.doris.nereids.properties.LogicalProperties;
|
|
|
|
|
import org.apache.doris.nereids.properties.OrderKey;
|
|
|
|
|
import org.apache.doris.nereids.trees.expressions.EqualTo;
|
|
|
|
|
import org.apache.doris.nereids.trees.expressions.Expression;
|
|
|
|
|
import org.apache.doris.nereids.trees.expressions.ExprId;
|
|
|
|
|
import org.apache.doris.nereids.trees.expressions.NamedExpression;
|
|
|
|
|
import org.apache.doris.nereids.trees.expressions.SlotReference;
|
|
|
|
|
import org.apache.doris.nereids.trees.expressions.literal.Literal;
|
|
|
|
|
@ -48,144 +48,173 @@ import mockit.Mocked;
|
|
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
// TODO: need more detailed test
|
|
|
|
|
public class PlanEqualsTest {
|
|
|
|
|
/* *************************** Logical *************************** */
|
|
|
|
|
@Test
|
|
|
|
|
public void testLogicalAggregate(@Mocked Plan child) {
|
|
|
|
|
List<Expression> groupByExprList = Lists.newArrayList();
|
|
|
|
|
List<NamedExpression> outputExpressionList = ImmutableList.of(
|
|
|
|
|
new SlotReference("a", new BigIntType(), true, Lists.newArrayList())
|
|
|
|
|
);
|
|
|
|
|
LogicalAggregate<Plan> actual = new LogicalAggregate<>(Lists.newArrayList(), ImmutableList.of(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
child);
|
|
|
|
|
|
|
|
|
|
LogicalAggregate one = new LogicalAggregate(groupByExprList, outputExpressionList, child);
|
|
|
|
|
Assertions.assertEquals(one, one);
|
|
|
|
|
LogicalAggregate<Plan> expected = new LogicalAggregate<>(Lists.newArrayList(), ImmutableList.of(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
List<Expression> groupByExprList1 = Lists.newArrayList();
|
|
|
|
|
List<NamedExpression> outputExpressionList1 = ImmutableList.of(
|
|
|
|
|
new SlotReference("b", new BigIntType(), true, Lists.newArrayList())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
LogicalAggregate two = new LogicalAggregate(groupByExprList1, outputExpressionList1, child);
|
|
|
|
|
Assertions.assertNotEquals(one, two);
|
|
|
|
|
LogicalAggregate<Plan> unexpected = new LogicalAggregate<>(Lists.newArrayList(), ImmutableList.of(
|
|
|
|
|
new SlotReference(new ExprId(0), "b", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testLogicalFilter(@Mocked Plan child) {
|
|
|
|
|
Expression predicate = new EqualTo(Literal.of(1), Literal.of(2));
|
|
|
|
|
LogicalFilter logicalFilter = new LogicalFilter(predicate, child);
|
|
|
|
|
Assertions.assertEquals(logicalFilter, logicalFilter);
|
|
|
|
|
LogicalFilter<Plan> actual = new LogicalFilter<>(new EqualTo(Literal.of(1), Literal.of(1)), child);
|
|
|
|
|
|
|
|
|
|
Expression predicate1 = new EqualTo(Literal.of(1), Literal.of(1));
|
|
|
|
|
LogicalFilter logicalFilter1 = new LogicalFilter(predicate1, child);
|
|
|
|
|
Assertions.assertNotEquals(logicalFilter, logicalFilter1);
|
|
|
|
|
LogicalFilter<Plan> expected = new LogicalFilter<>(new EqualTo(Literal.of(1), Literal.of(1)), child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
LogicalFilter<Plan> unexpected = new LogicalFilter<>(new EqualTo(Literal.of(1), Literal.of(2)), child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testLogicalJoin(@Mocked Plan left, @Mocked Plan right) {
|
|
|
|
|
Expression condition = new EqualTo(
|
|
|
|
|
new SlotReference("a", new BigIntType(), true, Lists.newArrayList()),
|
|
|
|
|
new SlotReference("b", new BigIntType(), true, Lists.newArrayList())
|
|
|
|
|
);
|
|
|
|
|
LogicalJoin innerJoin = new LogicalJoin(JoinType.INNER_JOIN, Lists.newArrayList(condition),
|
|
|
|
|
LogicalJoin<Plan, Plan> actual = new LogicalJoin<>(JoinType.INNER_JOIN, Lists.newArrayList(new EqualTo(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList()),
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()))),
|
|
|
|
|
Optional.empty(), left, right);
|
|
|
|
|
Assertions.assertEquals(innerJoin, innerJoin);
|
|
|
|
|
|
|
|
|
|
// Notice: condition1 != condition, so following is `assertNotEquals`.
|
|
|
|
|
// Because SlotReference.exprId is UUID.
|
|
|
|
|
Expression condition1 = new EqualTo(
|
|
|
|
|
new SlotReference("a", new BigIntType(), true, Lists.newArrayList()),
|
|
|
|
|
new SlotReference("b", new BigIntType(), true, Lists.newArrayList())
|
|
|
|
|
);
|
|
|
|
|
LogicalJoin innerJoin1 = new LogicalJoin(JoinType.INNER_JOIN, Lists.newArrayList(condition1),
|
|
|
|
|
LogicalJoin<Plan, Plan> expected = new LogicalJoin<>(JoinType.INNER_JOIN, Lists.newArrayList(new EqualTo(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList()),
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()))),
|
|
|
|
|
Optional.empty(), left, right);
|
|
|
|
|
Assertions.assertNotEquals(innerJoin, innerJoin1);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
Expression condition2 = new EqualTo(
|
|
|
|
|
LogicalJoin<Plan, Plan> unexpected = new LogicalJoin<>(JoinType.INNER_JOIN, Lists.newArrayList(new EqualTo(
|
|
|
|
|
new SlotReference("a", new BigIntType(), false, Lists.newArrayList()),
|
|
|
|
|
new SlotReference("b", new BigIntType(), true, Lists.newArrayList())
|
|
|
|
|
);
|
|
|
|
|
LogicalJoin innerJoin2 = new LogicalJoin(JoinType.INNER_JOIN, Lists.newArrayList(condition2),
|
|
|
|
|
new SlotReference("b", new BigIntType(), true, Lists.newArrayList()))),
|
|
|
|
|
Optional.empty(), left, right);
|
|
|
|
|
Assertions.assertNotEquals(innerJoin, innerJoin2);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testLogicalOlapScan() {
|
|
|
|
|
LogicalOlapScan scan1 = PlanConstructor.newLogicalOlapScan(0, "table", 0);
|
|
|
|
|
LogicalOlapScan scan2 = PlanConstructor.newLogicalOlapScan(0, "table", 0);
|
|
|
|
|
LogicalOlapScan actual = PlanConstructor.newLogicalOlapScan(0, "table", 0);
|
|
|
|
|
|
|
|
|
|
Assertions.assertEquals(scan1, scan2);
|
|
|
|
|
LogicalOlapScan expected = PlanConstructor.newLogicalOlapScan(0, "table", 0);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
LogicalOlapScan unexpected = PlanConstructor.newLogicalOlapScan(1, "table", 0);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testLogicalProject(@Mocked Plan child) {
|
|
|
|
|
// TODO: Depend on NamedExpression Equals
|
|
|
|
|
SlotReference aSlot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
|
|
|
|
|
List<NamedExpression> projects = ImmutableList.of(aSlot);
|
|
|
|
|
LogicalProject logicalProject = new LogicalProject(projects, child);
|
|
|
|
|
Assertions.assertEquals(logicalProject, logicalProject);
|
|
|
|
|
LogicalProject<Plan> actual = new LogicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
child);
|
|
|
|
|
|
|
|
|
|
LogicalProject logicalProjectWithSameSlot = new LogicalProject(ImmutableList.of(aSlot), child);
|
|
|
|
|
Assertions.assertEquals(logicalProject, logicalProjectWithSameSlot);
|
|
|
|
|
LogicalProject<Plan> expected = new LogicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
SlotReference a1Slot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
|
|
|
|
|
LogicalProject a1LogicalProject = new LogicalProject(ImmutableList.of(a1Slot), child);
|
|
|
|
|
Assertions.assertNotEquals(logicalProject, a1LogicalProject);
|
|
|
|
|
LogicalProject<Plan> unexpected1 = new LogicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(1), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected1, actual);
|
|
|
|
|
|
|
|
|
|
SlotReference bSlot = new SlotReference("b", new BigIntType(), true, Lists.newArrayList());
|
|
|
|
|
LogicalProject bLogicalProject1 = new LogicalProject(ImmutableList.of(bSlot), child);
|
|
|
|
|
Assertions.assertNotEquals(logicalProject, bLogicalProject1);
|
|
|
|
|
LogicalProject<Plan> unexpected2 = new LogicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected2, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testLogicalSort(@Mocked Plan child) {
|
|
|
|
|
// TODO: Depend on List<OrderKey> Equals
|
|
|
|
|
List<OrderKey> orderKeyList = Lists.newArrayList();
|
|
|
|
|
LogicalSort logicalSort = new LogicalSort(orderKeyList, child);
|
|
|
|
|
Assertions.assertEquals(logicalSort, logicalSort);
|
|
|
|
|
LogicalSort<Plan> actual = new LogicalSort<>(
|
|
|
|
|
ImmutableList.of(new OrderKey(
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()), true,
|
|
|
|
|
true)),
|
|
|
|
|
child);
|
|
|
|
|
|
|
|
|
|
List<OrderKey> orderKeyListClone = Lists.newArrayList();
|
|
|
|
|
LogicalSort logicalSortClone = new LogicalSort(orderKeyListClone, child);
|
|
|
|
|
Assertions.assertEquals(logicalSort, logicalSortClone);
|
|
|
|
|
LogicalSort<Plan> expected = new LogicalSort<>(
|
|
|
|
|
ImmutableList.of(new OrderKey(
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()), true,
|
|
|
|
|
true)),
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
LogicalSort<Plan> unexpected = new LogicalSort<>(
|
|
|
|
|
ImmutableList.of(new OrderKey(
|
|
|
|
|
new SlotReference(new ExprId(1), "a", new BigIntType(), true, Lists.newArrayList()), true,
|
|
|
|
|
true)),
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* *************************** Physical *************************** */
|
|
|
|
|
@Test
|
|
|
|
|
public void testPhysicalAggregate(@Mocked Plan child, @Mocked LogicalProperties logicalProperties) {
|
|
|
|
|
List<Expression> groupByExprList = Lists.newArrayList();
|
|
|
|
|
SlotReference slotReference = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
|
|
|
|
|
List<NamedExpression> outputExpressionList = ImmutableList.of(slotReference);
|
|
|
|
|
List<Expression> partitionExprList = Lists.newArrayList();
|
|
|
|
|
AggPhase aggPhase = AggPhase.LOCAL;
|
|
|
|
|
boolean usingStream = true;
|
|
|
|
|
List<NamedExpression> outputExpressionList = ImmutableList.of(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList()));
|
|
|
|
|
PhysicalAggregate<Plan> actual = new PhysicalAggregate<>(Lists.newArrayList(), outputExpressionList,
|
|
|
|
|
Lists.newArrayList(), AggPhase.LOCAL, true, logicalProperties, child);
|
|
|
|
|
|
|
|
|
|
PhysicalAggregate physicalAggregate = new PhysicalAggregate(groupByExprList, outputExpressionList,
|
|
|
|
|
partitionExprList, aggPhase, usingStream, logicalProperties, child);
|
|
|
|
|
Assertions.assertEquals(physicalAggregate, physicalAggregate);
|
|
|
|
|
List<NamedExpression> outputExpressionList1 = ImmutableList.of(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList()));
|
|
|
|
|
PhysicalAggregate<Plan> expected = new PhysicalAggregate<>(Lists.newArrayList(),
|
|
|
|
|
outputExpressionList1,
|
|
|
|
|
Lists.newArrayList(), AggPhase.LOCAL, true, logicalProperties, child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
List<NamedExpression> outputExpressionList2 = ImmutableList.of(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList()));
|
|
|
|
|
PhysicalAggregate<Plan> unexpected = new PhysicalAggregate<>(Lists.newArrayList(),
|
|
|
|
|
outputExpressionList2,
|
|
|
|
|
Lists.newArrayList(), AggPhase.LOCAL, false, logicalProperties, child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testPhysicalFilter(@Mocked Plan child, @Mocked LogicalProperties logicalProperties) {
|
|
|
|
|
Expression predicate = new EqualTo(Literal.of(1), Literal.of(2));
|
|
|
|
|
PhysicalFilter<Plan> actual = new PhysicalFilter<>(new EqualTo(Literal.of(1), Literal.of(2)),
|
|
|
|
|
logicalProperties, child);
|
|
|
|
|
|
|
|
|
|
PhysicalFilter physicalFilter = new PhysicalFilter(predicate, logicalProperties, child);
|
|
|
|
|
Assertions.assertEquals(physicalFilter, physicalFilter);
|
|
|
|
|
PhysicalFilter<Plan> expected = new PhysicalFilter<>(new EqualTo(Literal.of(1), Literal.of(2)),
|
|
|
|
|
logicalProperties, child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
PhysicalFilter<Plan> unexpected = new PhysicalFilter<>(new EqualTo(Literal.of(1), Literal.of(1)),
|
|
|
|
|
logicalProperties, child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testPhysicalJoin(@Mocked Plan left, @Mocked Plan right, @Mocked LogicalProperties logicalProperties) {
|
|
|
|
|
Expression expression = new EqualTo(Literal.of(1), Literal.of(2));
|
|
|
|
|
PhysicalHashJoin<Plan, Plan> actual = new PhysicalHashJoin<>(JoinType.INNER_JOIN,
|
|
|
|
|
Lists.newArrayList(new EqualTo(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList()),
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()))),
|
|
|
|
|
Optional.empty(), logicalProperties, left, right);
|
|
|
|
|
|
|
|
|
|
PhysicalHashJoin innerJoin = new PhysicalHashJoin(JoinType.INNER_JOIN, Lists.newArrayList(expression),
|
|
|
|
|
Optional.empty(),
|
|
|
|
|
logicalProperties, left,
|
|
|
|
|
right);
|
|
|
|
|
Assertions.assertEquals(innerJoin, innerJoin);
|
|
|
|
|
PhysicalHashJoin<Plan, Plan> expected = new PhysicalHashJoin<>(JoinType.INNER_JOIN,
|
|
|
|
|
Lists.newArrayList(new EqualTo(
|
|
|
|
|
new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList()),
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()))),
|
|
|
|
|
Optional.empty(), logicalProperties, left, right);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
PhysicalHashJoin<Plan, Plan> unexpected = new PhysicalHashJoin<>(JoinType.INNER_JOIN,
|
|
|
|
|
Lists.newArrayList(new EqualTo(
|
|
|
|
|
new SlotReference("a", new BigIntType(), false, Lists.newArrayList()),
|
|
|
|
|
new SlotReference("b", new BigIntType(), true, Lists.newArrayList()))),
|
|
|
|
|
Optional.empty(), logicalProperties, left, right);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@ -193,48 +222,76 @@ public class PlanEqualsTest {
|
|
|
|
|
@Mocked LogicalProperties logicalProperties,
|
|
|
|
|
@Mocked OlapTable olapTable,
|
|
|
|
|
@Mocked DistributionSpecHash distributionSpecHash) {
|
|
|
|
|
List<String> qualifier = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
ArrayList<Long> selectedTabletId = Lists.newArrayList();
|
|
|
|
|
List<Long> selectedTabletId = Lists.newArrayList();
|
|
|
|
|
for (Partition partition : olapTable.getAllPartitions()) {
|
|
|
|
|
selectedTabletId.addAll(partition.getBaseIndex().getTabletIdsInOrder());
|
|
|
|
|
}
|
|
|
|
|
PhysicalOlapScan olapScan = new PhysicalOlapScan(olapTable, qualifier, olapTable.getBaseIndexId(),
|
|
|
|
|
|
|
|
|
|
PhysicalOlapScan actual = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"), olapTable.getBaseIndexId(),
|
|
|
|
|
selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash, Optional.empty(),
|
|
|
|
|
logicalProperties);
|
|
|
|
|
|
|
|
|
|
Assertions.assertEquals(olapScan, olapScan);
|
|
|
|
|
PhysicalOlapScan expected = new PhysicalOlapScan(olapTable, Lists.newArrayList("a"),
|
|
|
|
|
olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash,
|
|
|
|
|
Optional.empty(), logicalProperties);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
PhysicalOlapScan unexpected = new PhysicalOlapScan(olapTable, Lists.newArrayList("b"),
|
|
|
|
|
olapTable.getBaseIndexId(), selectedTabletId, olapTable.getPartitionIds(), distributionSpecHash,
|
|
|
|
|
Optional.empty(), logicalProperties);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testPhysicalProject(@Mocked Plan child, @Mocked LogicalProperties logicalProperties) {
|
|
|
|
|
|
|
|
|
|
// TODO: Depend on NamedExpression Equals
|
|
|
|
|
SlotReference aSlot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
|
|
|
|
|
List<NamedExpression> projects = ImmutableList.of(aSlot);
|
|
|
|
|
PhysicalProject physicalProject = new PhysicalProject(projects, logicalProperties, child);
|
|
|
|
|
Assertions.assertEquals(physicalProject, physicalProject);
|
|
|
|
|
|
|
|
|
|
PhysicalProject physicalProjectWithSameSlot = new PhysicalProject(ImmutableList.of(aSlot), logicalProperties,
|
|
|
|
|
PhysicalProject<Plan> actual = new PhysicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
logicalProperties,
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertEquals(physicalProject, physicalProjectWithSameSlot);
|
|
|
|
|
|
|
|
|
|
SlotReference a1Slot = new SlotReference("a", new BigIntType(), true, Lists.newArrayList());
|
|
|
|
|
PhysicalProject a1PhysicalProject = new PhysicalProject(ImmutableList.of(a1Slot), logicalProperties, child);
|
|
|
|
|
Assertions.assertNotEquals(physicalProject, a1PhysicalProject);
|
|
|
|
|
PhysicalProject<Plan> expected = new PhysicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(0), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
logicalProperties,
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
PhysicalProject<Plan> unexpected1 = new PhysicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(1), "a", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
logicalProperties,
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected1, actual);
|
|
|
|
|
|
|
|
|
|
PhysicalProject<Plan> unexpected2 = new PhysicalProject<>(
|
|
|
|
|
ImmutableList.of(new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList())),
|
|
|
|
|
logicalProperties,
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected2, actual);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testPhysicalSort(@Mocked Plan child, @Mocked LogicalProperties logicalProperties) {
|
|
|
|
|
// TODO: Depend on List<OrderKey> Equals
|
|
|
|
|
List<OrderKey> orderKeyList = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
PhysicalQuickSort physicalQuickSort = new PhysicalQuickSort(orderKeyList, logicalProperties, child);
|
|
|
|
|
Assertions.assertEquals(physicalQuickSort, physicalQuickSort);
|
|
|
|
|
|
|
|
|
|
List<OrderKey> orderKeyListClone = Lists.newArrayList();
|
|
|
|
|
PhysicalQuickSort physicalQuickSortClone = new PhysicalQuickSort(orderKeyListClone, logicalProperties,
|
|
|
|
|
PhysicalQuickSort<Plan> actual = new PhysicalQuickSort<>(
|
|
|
|
|
ImmutableList.of(new OrderKey(
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()), true,
|
|
|
|
|
true)),
|
|
|
|
|
logicalProperties,
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertEquals(physicalQuickSort, physicalQuickSortClone);
|
|
|
|
|
|
|
|
|
|
PhysicalQuickSort<Plan> expected = new PhysicalQuickSort<>(
|
|
|
|
|
ImmutableList.of(new OrderKey(
|
|
|
|
|
new SlotReference(new ExprId(1), "b", new BigIntType(), true, Lists.newArrayList()), true,
|
|
|
|
|
true)),
|
|
|
|
|
logicalProperties,
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertEquals(expected, actual);
|
|
|
|
|
|
|
|
|
|
PhysicalQuickSort<Plan> unexpected = new PhysicalQuickSort<>(
|
|
|
|
|
ImmutableList.of(new OrderKey(
|
|
|
|
|
new SlotReference(new ExprId(1), "a", new BigIntType(), true, Lists.newArrayList()), true,
|
|
|
|
|
true)),
|
|
|
|
|
logicalProperties,
|
|
|
|
|
child);
|
|
|
|
|
Assertions.assertNotEquals(unexpected, actual);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|