From 8fc79e3ee40f78f50fa7a2a84244cb6d1391bf95 Mon Sep 17 00:00:00 2001 From: Shuo Wang Date: Tue, 26 Jul 2022 12:26:02 +0800 Subject: [PATCH] rename aggregate properties (#11117) 1. Unify and refine property names in LogicalAggregate and PhysicalAggregate 2. Remove partitionExpressions in LogicalAggregate since it's a physical property, and should not appear in the logical plan. It should be generated when converting logical aggregate to physical aggregate or in enforcing rules. --- .../translator/PhysicalPlanTranslator.java | 6 +- .../nereids/rules/analysis/BindFunction.java | 4 +- .../rules/analysis/BindSlotReference.java | 4 +- .../rewrite/ExpressionOfPlanRewrite.java | 4 +- .../LogicalAggToPhysicalHashAgg.java | 8 +- .../rules/rewrite/AggregateDisassemble.java | 8 +- .../trees/plans/logical/LogicalAggregate.java | 96 ++++++------- .../plans/physical/PhysicalAggregate.java | 64 ++++----- .../logical/AggregateDisassembleTest.java | 126 +++++++++--------- 9 files changed, 155 insertions(+), 165 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java index f6c8731526..b314138116 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java @@ -149,8 +149,8 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor groupByExpressionList = aggregate.getGroupByExprList(); - List outputExpressionList = aggregate.getOutputExpressionList(); + List groupByExpressionList = aggregate.getGroupByExpressions(); + List outputExpressionList = aggregate.getOutputExpressions(); // 1. generate slot reference for each group expression List groupSlotList = Lists.newArrayList(); @@ -189,7 +189,7 @@ public class PhysicalPlanTranslator extends DefaultPlanVisitor partitionExpressionList = aggregate.getPartitionExprList(); + List partitionExpressionList = aggregate.getPartitionExpressions(); List execPartitionExpressions = partitionExpressionList.stream() .map(e -> ExpressionTranslator.translate(e, context)).collect(Collectors.toList()); DataPartition mergePartition = DataPartition.UNPARTITIONED; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindFunction.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindFunction.java index 102c5779e9..2aafcf6254 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindFunction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindFunction.java @@ -47,8 +47,8 @@ public class BindFunction implements AnalysisRuleFactory { ), RuleType.BINDING_AGGREGATE_FUNCTION.build( logicalAggregate().then(agg -> { - List groupBy = bind(agg.getGroupByExpressionList()); - List output = bind(agg.getOutputExpressionList()); + List groupBy = bind(agg.getGroupByExpressions()); + List output = bind(agg.getOutputExpressions()); return agg.withGroupByAndOutput(groupBy, output); }) ) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java index d9372d63c2..c76fb4b6a9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSlotReference.java @@ -73,8 +73,8 @@ public class BindSlotReference implements AnalysisRuleFactory { ), RuleType.BINDING_AGGREGATE_SLOT.build( logicalAggregate().then(agg -> { - List groupBy = bind(agg.getGroupByExpressionList(), agg.children(), agg); - List output = bind(agg.getOutputExpressionList(), agg.children(), agg); + List groupBy = bind(agg.getGroupByExpressions(), agg.children(), agg); + List output = bind(agg.getOutputExpressions(), agg.children(), agg); return agg.withGroupByAndOutput(groupBy, output); }) ), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rewrite/ExpressionOfPlanRewrite.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rewrite/ExpressionOfPlanRewrite.java index d4f91b2155..aaf1cc60ff 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rewrite/ExpressionOfPlanRewrite.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rewrite/ExpressionOfPlanRewrite.java @@ -87,10 +87,10 @@ public class ExpressionOfPlanRewrite implements RewriteRuleFactory { @Override public Rule build() { return logicalAggregate().then(agg -> { - List groupByExprs = agg.getGroupByExpressionList(); + List groupByExprs = agg.getGroupByExpressions(); List newGroupByExprs = rewriter.rewrite(groupByExprs); - List outputExpressions = agg.getOutputExpressionList(); + List outputExpressions = agg.getOutputExpressions(); List newOutputExpressions = outputExpressions.stream() .map(expr -> (NamedExpression) rewriter.rewrite(expr)).collect(Collectors.toList()); if (outputExpressions.containsAll(newOutputExpressions)) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalAggToPhysicalHashAgg.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalAggToPhysicalHashAgg.java index 10b8b46049..ecc59393d4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalAggToPhysicalHashAgg.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/LogicalAggToPhysicalHashAgg.java @@ -21,6 +21,8 @@ import org.apache.doris.nereids.rules.Rule; import org.apache.doris.nereids.rules.RuleType; import org.apache.doris.nereids.trees.plans.physical.PhysicalAggregate; +import com.google.common.collect.ImmutableList; + /** * Implementation rule that convert logical aggregation to physical hash aggregation. */ @@ -29,9 +31,9 @@ public class LogicalAggToPhysicalHashAgg extends OneImplementationRuleFactory { public Rule build() { return logicalAggregate().then(agg -> new PhysicalAggregate<>( // TODO: for use a function to judge whether use stream - agg.getGroupByExpressionList(), - agg.getOutputExpressionList(), - agg.getPartitionExprList(), + agg.getGroupByExpressions(), + agg.getOutputExpressions(), + ImmutableList.of(), agg.getAggPhase(), false, agg.getLogicalProperties(), diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java index e017a4b803..96031d31de 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AggregateDisassemble.java @@ -59,8 +59,8 @@ public class AggregateDisassemble extends OneRewriteRuleFactory { public Rule build() { return logicalAggregate().when(agg -> !agg.isDisassembled()).thenApply(ctx -> { LogicalAggregate aggregate = ctx.root; - List originOutputExprs = aggregate.getOutputExpressionList(); - List originGroupByExprs = aggregate.getGroupByExpressionList(); + List originOutputExprs = aggregate.getOutputExpressions(); + List originGroupByExprs = aggregate.getGroupByExpressions(); // 1. generate a map from local aggregate output to global aggregate expr substitution. // inputSubstitutionMap use for replacing expression in global aggregate @@ -80,7 +80,7 @@ public class AggregateDisassemble extends OneRewriteRuleFactory { // NOTICE: Ref: SlotReference, A: Alias, AF: AggregateFunction, #x: ExprId x // 2. collect local aggregate output expressions and local aggregate group by expression list Map inputSubstitutionMap = Maps.newHashMap(); - List localGroupByExprs = aggregate.getGroupByExpressionList(); + List localGroupByExprs = aggregate.getGroupByExpressions(); List localOutputExprs = Lists.newArrayList(); for (Expression originGroupByExpr : originGroupByExprs) { if (inputSubstitutionMap.containsKey(originGroupByExpr)) { @@ -111,7 +111,7 @@ public class AggregateDisassemble extends OneRewriteRuleFactory { } // 3. replace expression in globalOutputExprs and globalGroupByExprs - List globalOutputExprs = aggregate.getOutputExpressionList().stream() + List globalOutputExprs = aggregate.getOutputExpressions().stream() .map(e -> ExpressionReplacer.INSTANCE.visit(e, inputSubstitutionMap)) .map(NamedExpression.class::cast) .collect(Collectors.toList()); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java index 186f000ef1..0564fd3c19 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalAggregate.java @@ -51,62 +51,53 @@ import java.util.Optional; public class LogicalAggregate extends LogicalUnary { private final boolean disassembled; - private final List groupByExpressionList; - private final List outputExpressionList; - private final List partitionExprList; + private final List groupByExpressions; + private final List outputExpressions; private final AggPhase aggPhase; /** * Desc: Constructor for LogicalAggregate. */ - public LogicalAggregate(List groupByExpressionList, List outputExpressionList, - CHILD_TYPE child) { - this(groupByExpressionList, outputExpressionList, false, AggPhase.GLOBAL, child); + public LogicalAggregate( + List groupByExpressions, + List outputExpressions, + CHILD_TYPE child) { + this(groupByExpressions, outputExpressions, false, AggPhase.GLOBAL, child); } - public LogicalAggregate(List groupByExpressionList, - List outputExpressionList, - boolean disassembled, AggPhase aggPhase, CHILD_TYPE child) { - this(groupByExpressionList, outputExpressionList, null, disassembled, aggPhase, child); - } - - public LogicalAggregate(List groupByExpressionList, - List outputExpressionList, - List partitionExprList, - boolean disassembled, AggPhase aggPhase, - CHILD_TYPE child) { - this(groupByExpressionList, outputExpressionList, partitionExprList, disassembled, aggPhase, - Optional.empty(), Optional.empty(), child); + public LogicalAggregate( + List groupByExpressions, + List outputExpressions, + boolean disassembled, + AggPhase aggPhase, + CHILD_TYPE child) { + this(groupByExpressions, outputExpressions, disassembled, aggPhase, Optional.empty(), Optional.empty(), child); } /** * Whole parameters constructor for LogicalAggregate. */ - public LogicalAggregate(List groupByExpressionList, - List outputExpressionList, - List partitionExprList, - boolean disassembled, AggPhase aggPhase, - Optional groupExpression, - Optional logicalProperties, - CHILD_TYPE child) { + public LogicalAggregate( + List groupByExpressions, + List outputExpressions, + boolean disassembled, + AggPhase aggPhase, + Optional groupExpression, + Optional logicalProperties, + CHILD_TYPE child) { super(PlanType.LOGICAL_AGGREGATE, groupExpression, logicalProperties, child); - this.groupByExpressionList = groupByExpressionList; - this.outputExpressionList = outputExpressionList; - this.partitionExprList = partitionExprList; + this.groupByExpressions = groupByExpressions; + this.outputExpressions = outputExpressions; this.disassembled = disassembled; this.aggPhase = aggPhase; } - public List getPartitionExprList() { - return partitionExprList == null ? groupByExpressionList : partitionExprList; + public List getGroupByExpressions() { + return groupByExpressions; } - public List getGroupByExpressionList() { - return groupByExpressionList; - } - - public List getOutputExpressionList() { - return outputExpressionList; + public List getOutputExpressions() { + return outputExpressions; } public AggPhase getAggPhase() { @@ -115,14 +106,14 @@ public class LogicalAggregate extends LogicalUnary computeOutput(Plan input) { - return outputExpressionList.stream() + return outputExpressions.stream() .map(NamedExpression::toSlot) .collect(ImmutableList.toImmutableList()); } @@ -135,8 +126,8 @@ public class LogicalAggregate extends LogicalUnary getExpressions() { return new ImmutableList.Builder() - .addAll(groupByExpressionList) - .addAll(outputExpressionList) + .addAll(groupByExpressions) + .addAll(outputExpressions) .build(); } @@ -155,41 +146,36 @@ public class LogicalAggregate extends LogicalUnary withChildren(List children) { Preconditions.checkArgument(children.size() == 1); - return new LogicalAggregate(groupByExpressionList, outputExpressionList, - partitionExprList, disassembled, aggPhase, children.get(0)); + return new LogicalAggregate(groupByExpressions, outputExpressions, disassembled, aggPhase, children.get(0)); } @Override public LogicalAggregate withGroupExpression(Optional groupExpression) { - return new LogicalAggregate(groupByExpressionList, outputExpressionList, - partitionExprList, disassembled, aggPhase, groupExpression, + return new LogicalAggregate(groupByExpressions, outputExpressions, disassembled, aggPhase, groupExpression, Optional.of(logicalProperties), children.get(0)); } @Override public LogicalAggregate withLogicalProperties(Optional logicalProperties) { - return new LogicalAggregate(groupByExpressionList, outputExpressionList, - partitionExprList, disassembled, aggPhase, Optional.empty(), + return new LogicalAggregate(groupByExpressions, outputExpressions, disassembled, aggPhase, Optional.empty(), logicalProperties, children.get(0)); } public LogicalAggregate withGroupByAndOutput(List groupByExprList, List outputExpressionList) { - return new LogicalAggregate(groupByExprList, outputExpressionList, - partitionExprList, disassembled, aggPhase, child()); + return new LogicalAggregate(groupByExprList, outputExpressionList, disassembled, aggPhase, child()); } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalAggregate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalAggregate.java index b041f79b5b..9b1fff74b3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalAggregate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/PhysicalAggregate.java @@ -28,6 +28,7 @@ import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Objects; @@ -38,41 +39,41 @@ import java.util.Optional; */ public class PhysicalAggregate extends PhysicalUnary { - private final List groupByExprList; + private final List groupByExpressions; - private final List outputExpressionList; + private final List outputExpressions; - private final List partitionExprList; + private final List partitionExpressions; private final AggPhase aggPhase; private final boolean usingStream; - public PhysicalAggregate(List groupByExprList, List outputExpressionList, - List partitionExprList, AggPhase aggPhase, boolean usingStream, + public PhysicalAggregate(List groupByExpressions, List outputExpressions, + List partitionExpressions, AggPhase aggPhase, boolean usingStream, LogicalProperties logicalProperties, CHILD_TYPE child) { - this(groupByExprList, outputExpressionList, partitionExprList, aggPhase, usingStream, + this(groupByExpressions, outputExpressions, partitionExpressions, aggPhase, usingStream, Optional.empty(), logicalProperties, child); } /** * Constructor of PhysicalAggNode. * - * @param groupByExprList group by expr list. - * @param outputExpressionList agg expr list. - * @param partitionExprList partition expr list, used for analytic agg. + * @param groupByExpressions group by expr list. + * @param outputExpressions agg expr list. + * @param partitionExpressions partition expr list, used for analytic agg. * @param usingStream whether it's stream agg. */ - public PhysicalAggregate(List groupByExprList, List outputExpressionList, - List partitionExprList, AggPhase aggPhase, boolean usingStream, + public PhysicalAggregate(List groupByExpressions, List outputExpressions, + List partitionExpressions, AggPhase aggPhase, boolean usingStream, Optional groupExpression, LogicalProperties logicalProperties, CHILD_TYPE child) { super(PlanType.PHYSICAL_AGGREGATE, groupExpression, logicalProperties, child); - this.groupByExprList = groupByExprList; - this.outputExpressionList = outputExpressionList; + this.groupByExpressions = groupByExpressions; + this.outputExpressions = outputExpressions; this.aggPhase = aggPhase; - this.partitionExprList = partitionExprList; + this.partitionExpressions = partitionExpressions; this.usingStream = usingStream; } @@ -80,20 +81,20 @@ public class PhysicalAggregate extends PhysicalUnary getGroupByExprList() { - return groupByExprList; + public List getGroupByExpressions() { + return groupByExpressions; } - public List getOutputExpressionList() { - return outputExpressionList; + public List getOutputExpressions() { + return outputExpressions; } public boolean isUsingStream() { return usingStream; } - public List getPartitionExprList() { - return partitionExprList; + public List getPartitionExpressions() { + return partitionExpressions == null ? groupByExpressions : partitionExpressions; } @Override @@ -104,14 +105,15 @@ public class PhysicalAggregate extends PhysicalUnary getExpressions() { // TODO: partitionExprList maybe null. - return new ImmutableList.Builder().addAll(groupByExprList).addAll(outputExpressionList) - .addAll(partitionExprList).build(); + return new ImmutableList.Builder().addAll(groupByExpressions).addAll(outputExpressions) + .addAll(partitionExpressions).build(); } @Override public String toString() { - return "PhysicalAggregate ([key=" + groupByExprList - + "], [output=" + outputExpressionList + "])"; + return "PhysicalAggregate (phase: [" + aggPhase.name() + "], output: [" + + StringUtils.join(outputExpressions, ", ") + + "], groupBy: [" + StringUtils.join(groupByExpressions, ", ") + "])"; } /** @@ -125,34 +127,34 @@ public class PhysicalAggregate extends PhysicalUnary withChildren(List children) { Preconditions.checkArgument(children.size() == 1); - return new PhysicalAggregate<>(groupByExprList, outputExpressionList, partitionExprList, aggPhase, + return new PhysicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions, aggPhase, usingStream, logicalProperties, children.get(0)); } @Override public Plan withGroupExpression(Optional groupExpression) { - return new PhysicalAggregate<>(groupByExprList, outputExpressionList, partitionExprList, aggPhase, + return new PhysicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions, aggPhase, usingStream, groupExpression, logicalProperties, child()); } @Override public Plan withLogicalProperties(Optional logicalProperties) { - return new PhysicalAggregate<>(groupByExprList, outputExpressionList, partitionExprList, aggPhase, + return new PhysicalAggregate<>(groupByExpressions, outputExpressions, partitionExpressions, aggPhase, usingStream, Optional.empty(), logicalProperties.get(), child()); } } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java index a618e5743a..d27c3278b1 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/logical/AggregateDisassembleTest.java @@ -91,31 +91,31 @@ public class AggregateDisassembleTest { Expression localOutput1 = new Sum(rStudent.getOutput().get(0).toSlot()); Expression localGroupBy = rStudent.getOutput().get(2).toSlot(); - Assertions.assertEquals(2, local.getOutputExpressionList().size()); - Assertions.assertTrue(local.getOutputExpressionList().get(0) instanceof SlotReference); - Assertions.assertEquals(localOutput0, local.getOutputExpressionList().get(0)); - Assertions.assertTrue(local.getOutputExpressionList().get(1) instanceof Alias); - Assertions.assertEquals(localOutput1, local.getOutputExpressionList().get(1).child(0)); - Assertions.assertEquals(1, local.getGroupByExpressionList().size()); - Assertions.assertEquals(localGroupBy, local.getGroupByExpressionList().get(0)); + Assertions.assertEquals(2, local.getOutputExpressions().size()); + Assertions.assertTrue(local.getOutputExpressions().get(0) instanceof SlotReference); + Assertions.assertEquals(localOutput0, local.getOutputExpressions().get(0)); + Assertions.assertTrue(local.getOutputExpressions().get(1) instanceof Alias); + Assertions.assertEquals(localOutput1, local.getOutputExpressions().get(1).child(0)); + Assertions.assertEquals(1, local.getGroupByExpressions().size()); + Assertions.assertEquals(localGroupBy, local.getGroupByExpressions().get(0)); - Expression globalOutput0 = local.getOutputExpressionList().get(0).toSlot(); - Expression globalOutput1 = new Sum(local.getOutputExpressionList().get(1).toSlot()); - Expression globalGroupBy = local.getOutputExpressionList().get(0).toSlot(); + Expression globalOutput0 = local.getOutputExpressions().get(0).toSlot(); + Expression globalOutput1 = new Sum(local.getOutputExpressions().get(1).toSlot()); + Expression globalGroupBy = local.getOutputExpressions().get(0).toSlot(); - Assertions.assertEquals(2, global.getOutputExpressionList().size()); - Assertions.assertTrue(global.getOutputExpressionList().get(0) instanceof SlotReference); - Assertions.assertEquals(globalOutput0, global.getOutputExpressionList().get(0)); - Assertions.assertTrue(global.getOutputExpressionList().get(1) instanceof Alias); - Assertions.assertEquals(globalOutput1, global.getOutputExpressionList().get(1).child(0)); - Assertions.assertEquals(1, global.getGroupByExpressionList().size()); - Assertions.assertEquals(globalGroupBy, global.getGroupByExpressionList().get(0)); + Assertions.assertEquals(2, global.getOutputExpressions().size()); + Assertions.assertTrue(global.getOutputExpressions().get(0) instanceof SlotReference); + Assertions.assertEquals(globalOutput0, global.getOutputExpressions().get(0)); + Assertions.assertTrue(global.getOutputExpressions().get(1) instanceof Alias); + Assertions.assertEquals(globalOutput1, global.getOutputExpressions().get(1).child(0)); + Assertions.assertEquals(1, global.getGroupByExpressions().size()); + Assertions.assertEquals(globalGroupBy, global.getGroupByExpressions().get(0)); // check id: Assertions.assertEquals(outputExpressionList.get(0).getExprId(), - global.getOutputExpressionList().get(0).getExprId()); + global.getOutputExpressions().get(0).getExprId()); Assertions.assertEquals(outputExpressionList.get(1).getExprId(), - global.getOutputExpressionList().get(1).getExprId()); + global.getOutputExpressions().get(1).getExprId()); } /** @@ -150,31 +150,31 @@ public class AggregateDisassembleTest { Expression localOutput1 = new Sum(rStudent.getOutput().get(0).toSlot()); Expression localGroupBy = new Add(rStudent.getOutput().get(2).toSlot(), new IntegerLiteral(1)); - Assertions.assertEquals(2, local.getOutputExpressionList().size()); - Assertions.assertTrue(local.getOutputExpressionList().get(0) instanceof Alias); - Assertions.assertEquals(localOutput0, local.getOutputExpressionList().get(0).child(0)); - Assertions.assertTrue(local.getOutputExpressionList().get(1) instanceof Alias); - Assertions.assertEquals(localOutput1, local.getOutputExpressionList().get(1).child(0)); - Assertions.assertEquals(1, local.getGroupByExpressionList().size()); - Assertions.assertEquals(localGroupBy, local.getGroupByExpressionList().get(0)); + Assertions.assertEquals(2, local.getOutputExpressions().size()); + Assertions.assertTrue(local.getOutputExpressions().get(0) instanceof Alias); + Assertions.assertEquals(localOutput0, local.getOutputExpressions().get(0).child(0)); + Assertions.assertTrue(local.getOutputExpressions().get(1) instanceof Alias); + Assertions.assertEquals(localOutput1, local.getOutputExpressions().get(1).child(0)); + Assertions.assertEquals(1, local.getGroupByExpressions().size()); + Assertions.assertEquals(localGroupBy, local.getGroupByExpressions().get(0)); - Expression globalOutput0 = local.getOutputExpressionList().get(0).toSlot(); - Expression globalOutput1 = new Sum(local.getOutputExpressionList().get(1).toSlot()); - Expression globalGroupBy = local.getOutputExpressionList().get(0).toSlot(); + Expression globalOutput0 = local.getOutputExpressions().get(0).toSlot(); + Expression globalOutput1 = new Sum(local.getOutputExpressions().get(1).toSlot()); + Expression globalGroupBy = local.getOutputExpressions().get(0).toSlot(); - Assertions.assertEquals(2, global.getOutputExpressionList().size()); - Assertions.assertTrue(global.getOutputExpressionList().get(0) instanceof Alias); - Assertions.assertEquals(globalOutput0, global.getOutputExpressionList().get(0).child(0)); - Assertions.assertTrue(global.getOutputExpressionList().get(1) instanceof Alias); - Assertions.assertEquals(globalOutput1, global.getOutputExpressionList().get(1).child(0)); - Assertions.assertEquals(1, global.getGroupByExpressionList().size()); - Assertions.assertEquals(globalGroupBy, global.getGroupByExpressionList().get(0)); + Assertions.assertEquals(2, global.getOutputExpressions().size()); + Assertions.assertTrue(global.getOutputExpressions().get(0) instanceof Alias); + Assertions.assertEquals(globalOutput0, global.getOutputExpressions().get(0).child(0)); + Assertions.assertTrue(global.getOutputExpressions().get(1) instanceof Alias); + Assertions.assertEquals(globalOutput1, global.getOutputExpressions().get(1).child(0)); + Assertions.assertEquals(1, global.getGroupByExpressions().size()); + Assertions.assertEquals(globalGroupBy, global.getGroupByExpressions().get(0)); // check id: Assertions.assertEquals(outputExpressionList.get(0).getExprId(), - global.getOutputExpressionList().get(0).getExprId()); + global.getOutputExpressions().get(0).getExprId()); Assertions.assertEquals(outputExpressionList.get(1).getExprId(), - global.getOutputExpressionList().get(1).getExprId()); + global.getOutputExpressions().get(1).getExprId()); } /** @@ -205,21 +205,21 @@ public class AggregateDisassembleTest { Expression localOutput0 = new Sum(rStudent.getOutput().get(0).toSlot()); - Assertions.assertEquals(1, local.getOutputExpressionList().size()); - Assertions.assertTrue(local.getOutputExpressionList().get(0) instanceof Alias); - Assertions.assertEquals(localOutput0, local.getOutputExpressionList().get(0).child(0)); - Assertions.assertEquals(0, local.getGroupByExpressionList().size()); + Assertions.assertEquals(1, local.getOutputExpressions().size()); + Assertions.assertTrue(local.getOutputExpressions().get(0) instanceof Alias); + Assertions.assertEquals(localOutput0, local.getOutputExpressions().get(0).child(0)); + Assertions.assertEquals(0, local.getGroupByExpressions().size()); - Expression globalOutput0 = new Sum(local.getOutputExpressionList().get(0).toSlot()); + Expression globalOutput0 = new Sum(local.getOutputExpressions().get(0).toSlot()); - Assertions.assertEquals(1, global.getOutputExpressionList().size()); - Assertions.assertTrue(global.getOutputExpressionList().get(0) instanceof Alias); - Assertions.assertEquals(globalOutput0, global.getOutputExpressionList().get(0).child(0)); - Assertions.assertEquals(0, global.getGroupByExpressionList().size()); + Assertions.assertEquals(1, global.getOutputExpressions().size()); + Assertions.assertTrue(global.getOutputExpressions().get(0) instanceof Alias); + Assertions.assertEquals(globalOutput0, global.getOutputExpressions().get(0).child(0)); + Assertions.assertEquals(0, global.getGroupByExpressions().size()); // check id: Assertions.assertEquals(outputExpressionList.get(0).getExprId(), - global.getOutputExpressionList().get(0).getExprId()); + global.getOutputExpressions().get(0).getExprId()); } /** @@ -253,26 +253,26 @@ public class AggregateDisassembleTest { Expression localOutput1 = new Sum(rStudent.getOutput().get(0).toSlot()); Expression localGroupBy = rStudent.getOutput().get(2).toSlot(); - Assertions.assertEquals(2, local.getOutputExpressionList().size()); - Assertions.assertTrue(local.getOutputExpressionList().get(0) instanceof SlotReference); - Assertions.assertEquals(localOutput0, local.getOutputExpressionList().get(0)); - Assertions.assertTrue(local.getOutputExpressionList().get(1) instanceof Alias); - Assertions.assertEquals(localOutput1, local.getOutputExpressionList().get(1).child(0)); - Assertions.assertEquals(1, local.getGroupByExpressionList().size()); - Assertions.assertEquals(localGroupBy, local.getGroupByExpressionList().get(0)); + Assertions.assertEquals(2, local.getOutputExpressions().size()); + Assertions.assertTrue(local.getOutputExpressions().get(0) instanceof SlotReference); + Assertions.assertEquals(localOutput0, local.getOutputExpressions().get(0)); + Assertions.assertTrue(local.getOutputExpressions().get(1) instanceof Alias); + Assertions.assertEquals(localOutput1, local.getOutputExpressions().get(1).child(0)); + Assertions.assertEquals(1, local.getGroupByExpressions().size()); + Assertions.assertEquals(localGroupBy, local.getGroupByExpressions().get(0)); - Expression globalOutput0 = new Sum(local.getOutputExpressionList().get(1).toSlot()); - Expression globalGroupBy = local.getOutputExpressionList().get(0).toSlot(); + Expression globalOutput0 = new Sum(local.getOutputExpressions().get(1).toSlot()); + Expression globalGroupBy = local.getOutputExpressions().get(0).toSlot(); - Assertions.assertEquals(1, global.getOutputExpressionList().size()); - Assertions.assertTrue(global.getOutputExpressionList().get(0) instanceof Alias); - Assertions.assertEquals(globalOutput0, global.getOutputExpressionList().get(0).child(0)); - Assertions.assertEquals(1, global.getGroupByExpressionList().size()); - Assertions.assertEquals(globalGroupBy, global.getGroupByExpressionList().get(0)); + Assertions.assertEquals(1, global.getOutputExpressions().size()); + Assertions.assertTrue(global.getOutputExpressions().get(0) instanceof Alias); + Assertions.assertEquals(globalOutput0, global.getOutputExpressions().get(0).child(0)); + Assertions.assertEquals(1, global.getGroupByExpressions().size()); + Assertions.assertEquals(globalGroupBy, global.getGroupByExpressions().get(0)); // check id: Assertions.assertEquals(outputExpressionList.get(0).getExprId(), - global.getOutputExpressionList().get(0).getExprId()); + global.getOutputExpressions().get(0).getExprId()); } private Plan rewrite(Plan input) {