This is an automated email from the ASF dual-hosted git repository. xiangweiwei pushed a commit to branch lowerCaseBug in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 66073b8b47a485017e160b84a840a5cb1a2d0e75 Author: Alima777 <[email protected]> AuthorDate: Mon Jun 13 16:01:24 2022 +0800 Fix case sensitive bug in aggregation query --- .../db/mpp/plan/planner/LogicalPlanBuilder.java | 20 ++--- .../plan/planner/distribution/SourceRewriter.java | 6 +- .../plan/parameter/AggregationDescriptor.java | 65 ++++++++-------- .../plan/parameter/GroupByLevelDescriptor.java | 7 +- .../plan/analyze/AggregationDescriptorTest.java | 20 ++--- .../db/mpp/plan/plan/QueryLogicalPlanUtil.java | 90 +++++++++++----------- .../distribution/AggregationDistributionTest.java | 24 +++--- .../node/process/AggregationNodeSerdeTest.java | 36 ++++----- .../node/process/GroupByLevelNodeSerdeTest.java | 6 +- .../source/SeriesAggregationScanNodeSerdeTest.java | 2 +- 10 files changed, 139 insertions(+), 137 deletions(-) diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/LogicalPlanBuilder.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/LogicalPlanBuilder.java index a451623307..fde0f78372 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/LogicalPlanBuilder.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/LogicalPlanBuilder.java @@ -273,17 +273,17 @@ public class LogicalPlanBuilder { TypeProvider typeProvider, Map<PartialPath, List<AggregationDescriptor>> ascendingAggregations, Map<PartialPath, List<AggregationDescriptor>> descendingAggregations) { - AggregationType aggregationFunction = - AggregationType.valueOf(sourceExpression.getFunctionName().toUpperCase()); AggregationDescriptor aggregationDescriptor = - new AggregationDescriptor(aggregationFunction, curStep, sourceExpression.getExpressions()); + new AggregationDescriptor( + sourceExpression.getFunctionName(), curStep, sourceExpression.getExpressions()); if (curStep.isOutputPartial()) { updateTypeProviderByPartialAggregation(aggregationDescriptor, typeProvider); } PartialPath selectPath = ((TimeSeriesOperand) sourceExpression.getExpressions().get(0)).getPath(); if (!needCheckAscending - || SchemaUtils.isConsistentWithScanOrder(aggregationFunction, scanOrder)) { + || SchemaUtils.isConsistentWithScanOrder( + aggregationDescriptor.getAggregationType(), scanOrder)) { ascendingAggregations .computeIfAbsent(selectPath, key -> new ArrayList<>()) .add(aggregationDescriptor); @@ -511,12 +511,9 @@ public class LogicalPlanBuilder { OrderBy scanOrder) { List<GroupByLevelDescriptor> groupByLevelDescriptors = new ArrayList<>(); for (Expression groupedExpression : groupByLevelExpressions.keySet()) { - AggregationType aggregationFunction = - AggregationType.valueOf( - ((FunctionExpression) groupedExpression).getFunctionName().toUpperCase()); groupByLevelDescriptors.add( new GroupByLevelDescriptor( - aggregationFunction, + ((FunctionExpression) groupedExpression).getFunctionName(), curStep, groupByLevelExpressions.get(groupedExpression).stream() .map(Expression::getExpressions) @@ -569,11 +566,10 @@ public class LogicalPlanBuilder { .map( expression -> { Validate.isTrue(expression instanceof FunctionExpression); - AggregationType aggregationFunction = - AggregationType.valueOf( - ((FunctionExpression) expression).getFunctionName().toUpperCase()); return new AggregationDescriptor( - aggregationFunction, curStep, expression.getExpressions()); + ((FunctionExpression) expression).getFunctionName(), + curStep, + expression.getExpressions()); }) .collect(Collectors.toList()); } diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/distribution/SourceRewriter.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/distribution/SourceRewriter.java index 676d93b3b4..070256c39e 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/distribution/SourceRewriter.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/distribution/SourceRewriter.java @@ -306,7 +306,7 @@ public class SourceRewriter extends SimplePlanNodeRewriter<DistributionPlanConte descriptor -> { leafAggDescriptorList.add( new AggregationDescriptor( - descriptor.getAggregationType(), + descriptor.getAggregationFuncName(), AggregationStep.PARTIAL, descriptor.getInputExpressions())); }); @@ -320,7 +320,7 @@ public class SourceRewriter extends SimplePlanNodeRewriter<DistributionPlanConte descriptor -> { rootAggDescriptorList.add( new AggregationDescriptor( - descriptor.getAggregationType(), + descriptor.getAggregationFuncName(), AggregationStep.FINAL, descriptor.getInputExpressions())); }); @@ -488,7 +488,7 @@ public class SourceRewriter extends SimplePlanNodeRewriter<DistributionPlanConte descriptor -> { rootAggDescriptorList.add( new AggregationDescriptor( - descriptor.getAggregationType(), + descriptor.getAggregationFuncName(), context.isRoot ? AggregationStep.FINAL : AggregationStep.INTERMEDIATE, descriptor.getInputExpressions())); }); diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/AggregationDescriptor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/AggregationDescriptor.java index feff4fd15c..daf7955522 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/AggregationDescriptor.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/AggregationDescriptor.java @@ -36,8 +36,10 @@ import java.util.stream.Collectors; public class AggregationDescriptor { - // aggregation function name + // aggregation function type protected final AggregationType aggregationType; + // In case user's input is case-sensitive, we should keep the origin string. + protected final String aggregationFuncName; // indicate the input and output type protected AggregationStep step; @@ -56,24 +58,29 @@ public class AggregationDescriptor { private String parametersString; public AggregationDescriptor( - AggregationType aggregationType, AggregationStep step, List<Expression> inputExpressions) { - this.aggregationType = aggregationType; + String aggregationFuncName, AggregationStep step, List<Expression> inputExpressions) { + this.aggregationFuncName = aggregationFuncName; + this.aggregationType = AggregationType.valueOf(aggregationFuncName.toUpperCase()); this.step = step; this.inputExpressions = inputExpressions; } public AggregationDescriptor(AggregationDescriptor other) { + this.aggregationFuncName = other.aggregationFuncName; this.aggregationType = other.getAggregationType(); this.step = other.getStep(); this.inputExpressions = other.getInputExpressions(); } + public String getAggregationFuncName() { + return aggregationFuncName; + } + public List<String> getOutputColumnNames() { - List<AggregationType> outputAggregationTypes = - getActualAggregationTypes(step.isOutputPartial()); + List<String> outputAggregationNames = getActualAggregationNames(step.isOutputPartial()); List<String> outputColumnNames = new ArrayList<>(); - for (AggregationType funcName : outputAggregationTypes) { - outputColumnNames.add(funcName.toString().toLowerCase() + "(" + getParametersString() + ")"); + for (String funcName : outputAggregationNames) { + outputColumnNames.add(funcName + "(" + getParametersString() + ")"); } return outputColumnNames; } @@ -93,11 +100,10 @@ public class AggregationDescriptor { } public List<String> getInputColumnNames(Expression inputExpression) { - List<AggregationType> inputAggregationTypes = getActualAggregationTypes(step.isInputPartial()); + List<String> inputAggregationNames = getActualAggregationNames(step.isInputPartial()); List<String> inputColumnNames = new ArrayList<>(); - for (AggregationType funcName : inputAggregationTypes) { - inputColumnNames.add( - funcName.toString().toLowerCase() + "(" + inputExpression.getExpressionString() + ")"); + for (String funcName : inputAggregationNames) { + inputColumnNames.add(funcName + "(" + inputExpression.getExpressionString() + ")"); } return inputColumnNames; } @@ -113,29 +119,30 @@ public class AggregationDescriptor { return inputColumnNameToExpressionMap; } - protected List<AggregationType> getActualAggregationTypes(boolean isPartial) { - List<AggregationType> outputAggregationTypes = new ArrayList<>(); + /** Keep the lower case of function name for partial result, and origin value for others. */ + protected List<String> getActualAggregationNames(boolean isPartial) { + List<String> outputAggregationNames = new ArrayList<>(); if (isPartial) { switch (aggregationType) { case AVG: - outputAggregationTypes.add(AggregationType.COUNT); - outputAggregationTypes.add(AggregationType.SUM); + outputAggregationNames.add(AggregationType.COUNT.name().toLowerCase()); + outputAggregationNames.add(AggregationType.SUM.name().toLowerCase()); break; case FIRST_VALUE: - outputAggregationTypes.add(AggregationType.FIRST_VALUE); - outputAggregationTypes.add(AggregationType.MIN_TIME); + outputAggregationNames.add(AggregationType.FIRST_VALUE.name().toLowerCase()); + outputAggregationNames.add(AggregationType.MIN_TIME.name().toLowerCase()); break; case LAST_VALUE: - outputAggregationTypes.add(AggregationType.LAST_VALUE); - outputAggregationTypes.add(AggregationType.MAX_TIME); + outputAggregationNames.add(AggregationType.LAST_VALUE.name().toLowerCase()); + outputAggregationNames.add(AggregationType.MAX_TIME.name().toLowerCase()); break; default: - outputAggregationTypes.add(aggregationType); + outputAggregationNames.add(aggregationFuncName); } } else { - outputAggregationTypes.add(aggregationType); + outputAggregationNames.add(aggregationFuncName); } - return outputAggregationTypes; + return outputAggregationNames; } /** @@ -182,12 +189,11 @@ public class AggregationDescriptor { } public AggregationDescriptor deepClone() { - return new AggregationDescriptor( - this.getAggregationType(), this.getStep(), this.getInputExpressions()); + return new AggregationDescriptor(this); } public void serialize(ByteBuffer byteBuffer) { - ReadWriteIOUtils.write(aggregationType.ordinal(), byteBuffer); + ReadWriteIOUtils.write(aggregationFuncName, byteBuffer); step.serialize(byteBuffer); ReadWriteIOUtils.write(inputExpressions.size(), byteBuffer); for (Expression expression : inputExpressions) { @@ -196,7 +202,7 @@ public class AggregationDescriptor { } public void serialize(DataOutputStream stream) throws IOException { - ReadWriteIOUtils.write(aggregationType.ordinal(), stream); + ReadWriteIOUtils.write(aggregationFuncName, stream); step.serialize(stream); ReadWriteIOUtils.write(inputExpressions.size(), stream); for (Expression expression : inputExpressions) { @@ -205,8 +211,7 @@ public class AggregationDescriptor { } public static AggregationDescriptor deserialize(ByteBuffer byteBuffer) { - AggregationType aggregationType = - AggregationType.values()[ReadWriteIOUtils.readInt(byteBuffer)]; + String aggregationFuncName = ReadWriteIOUtils.readString(byteBuffer); AggregationStep step = AggregationStep.deserialize(byteBuffer); int inputExpressionsSize = ReadWriteIOUtils.readInt(byteBuffer); List<Expression> inputExpressions = new ArrayList<>(inputExpressionsSize); @@ -214,7 +219,7 @@ public class AggregationDescriptor { inputExpressions.add(Expression.deserialize(byteBuffer)); inputExpressionsSize--; } - return new AggregationDescriptor(aggregationType, step, inputExpressions); + return new AggregationDescriptor(aggregationFuncName, step, inputExpressions); } @Override @@ -237,6 +242,6 @@ public class AggregationDescriptor { } public String toString() { - return String.format("AggregationDescriptor(%s, %s)", aggregationType, step); + return String.format("AggregationDescriptor(%s, %s)", aggregationFuncName, step); } } diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByLevelDescriptor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByLevelDescriptor.java index 2d3dc2de60..651315f358 100644 --- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByLevelDescriptor.java +++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/parameter/GroupByLevelDescriptor.java @@ -20,7 +20,6 @@ package org.apache.iotdb.db.mpp.plan.planner.plan.parameter; import org.apache.iotdb.db.mpp.plan.expression.Expression; -import org.apache.iotdb.db.query.aggregation.AggregationType; import java.nio.ByteBuffer; import java.util.List; @@ -32,11 +31,11 @@ public class GroupByLevelDescriptor extends AggregationDescriptor { private final Expression outputExpression; public GroupByLevelDescriptor( - AggregationType aggregationType, + String aggregationFuncName, AggregationStep step, List<Expression> inputExpressions, Expression outputExpression) { - super(aggregationType, step, inputExpressions); + super(aggregationFuncName, step, inputExpressions); this.outputExpression = outputExpression; } @@ -67,7 +66,7 @@ public class GroupByLevelDescriptor extends AggregationDescriptor { public GroupByLevelDescriptor deepClone() { return new GroupByLevelDescriptor( - this.getAggregationType(), + this.getAggregationFuncName(), this.getStep(), this.getInputExpressions(), this.getOutputExpression()); diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/plan/analyze/AggregationDescriptorTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/plan/analyze/AggregationDescriptorTest.java index 4b8bbf6b00..ac4c846813 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/plan/analyze/AggregationDescriptorTest.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/plan/analyze/AggregationDescriptorTest.java @@ -61,38 +61,38 @@ public class AggregationDescriptorTest { static { aggregationDescriptorList.add( new AggregationDescriptor( - AggregationType.AVG, + AggregationType.AVG.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList(new TimeSeriesOperand(pathMap.get("root.sg.d1.s1"))))); aggregationDescriptorList.add( new AggregationDescriptor( - AggregationType.SUM, + AggregationType.SUM.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(pathMap.get("root.sg.d1.s1"))))); aggregationDescriptorList.add( new AggregationDescriptor( - AggregationType.AVG, + AggregationType.AVG.name().toLowerCase(), AggregationStep.INTERMEDIATE, Collections.singletonList(new TimeSeriesOperand(pathMap.get("root.sg.d1.s1"))))); aggregationDescriptorList.add( new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.INTERMEDIATE, Collections.singletonList(new TimeSeriesOperand(pathMap.get("root.sg.d1.s1"))))); aggregationDescriptorList.add( new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(pathMap.get("root.sg.d1.s1"))))); aggregationDescriptorList.add( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(pathMap.get("root.sg.d1.s1"))))); groupByLevelDescriptorList.add( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(pathMap.get("root.sg.d2.s1")), @@ -100,7 +100,7 @@ public class AggregationDescriptorTest { new TimeSeriesOperand(pathMap.get("root.sg.*.s1")))); groupByLevelDescriptorList.add( new GroupByLevelDescriptor( - AggregationType.AVG, + AggregationType.AVG.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(pathMap.get("root.sg.d1.s1")), @@ -108,7 +108,7 @@ public class AggregationDescriptorTest { new TimeSeriesOperand(pathMap.get("root.sg.*.s1")))); groupByLevelDescriptorList.add( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.INTERMEDIATE, Arrays.asList( new TimeSeriesOperand(pathMap.get("root.sg.d2.s1")), @@ -116,7 +116,7 @@ public class AggregationDescriptorTest { new TimeSeriesOperand(pathMap.get("root.sg.*.s1")))); groupByLevelDescriptorList.add( new GroupByLevelDescriptor( - AggregationType.AVG, + AggregationType.AVG.name().toLowerCase(), AggregationStep.INTERMEDIATE, Arrays.asList( new TimeSeriesOperand(pathMap.get("root.sg.d1.s1")), diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java index 9eda86a8d0..eafc52d1b0 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/QueryLogicalPlanUtil.java @@ -372,12 +372,12 @@ public class QueryLogicalPlanUtil { (AlignedPath) schemaMap.get("root.sg.d2.a"), Arrays.asList( new AggregationDescriptor( - AggregationType.FIRST_VALUE, + AggregationType.FIRST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s1")))), new AggregationDescriptor( - AggregationType.SUM, + AggregationType.SUM.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s2"))))), @@ -389,7 +389,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d2.s1"), Collections.singletonList( new AggregationDescriptor( - AggregationType.FIRST_VALUE, + AggregationType.FIRST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1"))))), @@ -401,7 +401,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d1.s1"), Collections.singletonList( new AggregationDescriptor( - AggregationType.FIRST_VALUE, + AggregationType.FIRST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))))), @@ -413,7 +413,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d2.s2"), Collections.singletonList( new AggregationDescriptor( - AggregationType.SUM, + AggregationType.SUM.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s2"))))), @@ -425,7 +425,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d1.s2"), Collections.singletonList( new AggregationDescriptor( - AggregationType.SUM, + AggregationType.SUM.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s2"))))), @@ -437,7 +437,7 @@ public class QueryLogicalPlanUtil { new AlignedPath((MeasurementPath) schemaMap.get("root.sg.d2.a.s1")), Collections.singletonList( new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s1"))))), @@ -449,7 +449,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d2.s1"), Collections.singletonList( new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1"))))), @@ -461,7 +461,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d1.s1"), Collections.singletonList( new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))))), @@ -500,17 +500,17 @@ public class QueryLogicalPlanUtil { (AlignedPath) schemaMap.get("root.sg.d2.a"), Arrays.asList( new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s1")))), new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s1")))), new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s2"))))), @@ -522,12 +522,12 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d2.s1"), Arrays.asList( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1"))))), @@ -539,12 +539,12 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d1.s1"), Arrays.asList( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))))), @@ -556,7 +556,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d2.s2"), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s2"))))), @@ -568,7 +568,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d1.s2"), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s2"))))), @@ -589,40 +589,40 @@ public class QueryLogicalPlanUtil { sourceNodeList, Arrays.asList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")), new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))), new TimeSeriesOperand(schemaMap.get("root.sg.*.s1"))), new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s1"))), new TimeSeriesOperand(schemaMap.get("root.sg.*.*.s1"))), new GroupByLevelDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s2")), new TimeSeriesOperand(schemaMap.get("root.sg.d2.s2"))), new TimeSeriesOperand(schemaMap.get("root.sg.*.s2"))), new GroupByLevelDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s2"))), new TimeSeriesOperand(schemaMap.get("root.sg.*.*.s2"))), new GroupByLevelDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")), new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))), new TimeSeriesOperand(schemaMap.get("root.sg.*.s1"))), new GroupByLevelDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.a.s1"))), @@ -652,12 +652,12 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d1.s1"), Arrays.asList( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))))), @@ -669,7 +669,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d1.s2"), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s2"))))), @@ -687,12 +687,12 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d2.s1"), Arrays.asList( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1"))))), @@ -704,7 +704,7 @@ public class QueryLogicalPlanUtil { (MeasurementPath) schemaMap.get("root.sg.d2.s2"), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s2"))))), @@ -802,32 +802,32 @@ public class QueryLogicalPlanUtil { Collections.singletonList(filterNode), Arrays.asList( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")))), new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1")))), new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s2")))), new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s2")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))))), @@ -840,21 +840,21 @@ public class QueryLogicalPlanUtil { Collections.singletonList(aggregationNode), Arrays.asList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")), new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))), new TimeSeriesOperand(schemaMap.get("root.sg.*.s1"))), new GroupByLevelDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s2")), new TimeSeriesOperand(schemaMap.get("root.sg.d2.s2"))), new TimeSeriesOperand(schemaMap.get("root.sg.*.s2"))), new GroupByLevelDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")), @@ -923,17 +923,17 @@ public class QueryLogicalPlanUtil { Collections.singletonList(filterNode1), Arrays.asList( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1")))), new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s2")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d1.s1"))))), @@ -981,17 +981,17 @@ public class QueryLogicalPlanUtil { Collections.singletonList(filterNode2), Arrays.asList( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1")))), new AggregationDescriptor( - AggregationType.MAX_VALUE, + AggregationType.MAX_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s2")))), new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList( new TimeSeriesOperand(schemaMap.get("root.sg.d2.s1"))))), diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/distribution/AggregationDistributionTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/distribution/AggregationDistributionTest.java index fabc041d97..c250dd7e13 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/distribution/AggregationDistributionTest.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/distribution/AggregationDistributionTest.java @@ -216,7 +216,7 @@ public class AggregationDistributionTest { genAggregationSourceNode(queryId, d2s1Path, AggregationType.COUNT)), Collections.singletonList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(new PartialPath(d1s1Path)), @@ -253,7 +253,7 @@ public class AggregationDistributionTest { genAggregationSourceNode(queryId, d4s1Path, AggregationType.COUNT)), Collections.singletonList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(new PartialPath(d3s1Path)), @@ -312,7 +312,7 @@ public class AggregationDistributionTest { Collections.singletonList(slidingWindowAggregationNode), Collections.singletonList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(new PartialPath(d3s1Path)), @@ -386,12 +386,12 @@ public class AggregationDistributionTest { genAggregationSourceNode(queryId, d1s2Path, AggregationType.COUNT)), Arrays.asList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(new PartialPath(d1s1Path))), new TimeSeriesOperand(new PartialPath(groupedPathS1))), new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(new PartialPath(d1s2Path))), new TimeSeriesOperand(new PartialPath(groupedPathS2)))), @@ -443,14 +443,14 @@ public class AggregationDistributionTest { genAggregationSourceNode(queryId, d2s1Path, AggregationType.COUNT)), Arrays.asList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(new PartialPath(d1s1Path)), new TimeSeriesOperand(new PartialPath(d2s1Path))), new TimeSeriesOperand(new PartialPath(groupedPathS1))), new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(new PartialPath(d1s2Path))), new TimeSeriesOperand(new PartialPath(groupedPathS2)))), @@ -515,14 +515,14 @@ public class AggregationDistributionTest { Collections.singletonList(slidingWindowAggregationNode), Arrays.asList( new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(new PartialPath(d1s1Path)), new TimeSeriesOperand(new PartialPath(d2s1Path))), new TimeSeriesOperand(new PartialPath(groupedPathS1))), new GroupByLevelDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(new PartialPath(d1s2Path))), new TimeSeriesOperand(new PartialPath(groupedPathS2)))), @@ -649,7 +649,9 @@ public class AggregationDistributionTest { .map( path -> new AggregationDescriptor( - type, step, Collections.singletonList(new TimeSeriesOperand(path)))) + type.name().toLowerCase(), + step, + Collections.singletonList(new TimeSeriesOperand(path)))) .collect(Collectors.toList()), groupByTimeParameter, OrderBy.TIMESTAMP_ASC); @@ -660,7 +662,7 @@ public class AggregationDistributionTest { List<AggregationDescriptor> descriptors = new ArrayList<>(); descriptors.add( new AggregationDescriptor( - type, + type.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(new PartialPath(path))))); diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/AggregationNodeSerdeTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/AggregationNodeSerdeTest.java index 7a42e4c85c..5208c0913f 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/AggregationNodeSerdeTest.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/AggregationNodeSerdeTest.java @@ -57,7 +57,7 @@ public class AggregationNodeSerdeTest { new MeasurementPath("root.sg.d1.s1", TSDataType.BOOLEAN), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_TIME, + AggregationType.MAX_TIME.name().toLowerCase(), AggregationStep.INTERMEDIATE, Collections.singletonList( new TimeSeriesOperand(new PartialPath("root.sg.d1.s1"))))), @@ -71,7 +71,7 @@ public class AggregationNodeSerdeTest { Collections.singletonList(seriesAggregationScanNode), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_TIME, + AggregationType.MAX_TIME.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList( new TimeSeriesOperand(new PartialPath("root.sg.d1.s1"))))), @@ -96,7 +96,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -113,7 +113,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -129,7 +129,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -142,7 +142,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -164,7 +164,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -180,7 +180,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -193,7 +193,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -214,7 +214,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -230,7 +230,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -243,7 +243,7 @@ public class AggregationNodeSerdeTest { for (AggregationType aggregationType : aggregationTypeList) { descriptorList.add( new AggregationDescriptor( - aggregationType, + aggregationType.name().toLowerCase(), AggregationStep.SINGLE, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); } @@ -261,12 +261,12 @@ public class AggregationNodeSerdeTest { List<AggregationDescriptor> descriptorList = new ArrayList<>(); descriptorList.add( new AggregationDescriptor( - AggregationType.AVG, + AggregationType.AVG.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); descriptorList.add( new AggregationDescriptor( - AggregationType.COUNT, + AggregationType.COUNT.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath2)))); @@ -279,12 +279,12 @@ public class AggregationNodeSerdeTest { descriptorList = new ArrayList<>(); descriptorList.add( new AggregationDescriptor( - AggregationType.FIRST_VALUE, + AggregationType.FIRST_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); descriptorList.add( new AggregationDescriptor( - AggregationType.MIN_TIME, + AggregationType.MIN_TIME.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath2)))); @@ -296,12 +296,12 @@ public class AggregationNodeSerdeTest { descriptorList = new ArrayList<>(); descriptorList.add( new AggregationDescriptor( - AggregationType.LAST_VALUE, + AggregationType.LAST_VALUE.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath1)))); descriptorList.add( new AggregationDescriptor( - AggregationType.MAX_TIME, + AggregationType.MAX_TIME.name().toLowerCase(), AggregationStep.PARTIAL, Collections.singletonList(new TimeSeriesOperand(seriesPath2)))); diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/GroupByLevelNodeSerdeTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/GroupByLevelNodeSerdeTest.java index 862e8a9796..0336aa2ae3 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/GroupByLevelNodeSerdeTest.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/process/GroupByLevelNodeSerdeTest.java @@ -54,7 +54,7 @@ public class GroupByLevelNodeSerdeTest { new MeasurementPath("root.sg.d1.s1", TSDataType.INT32), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_TIME, + AggregationType.MAX_TIME.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList( new TimeSeriesOperand(new PartialPath("root.sg.d1.s1"))))), @@ -68,7 +68,7 @@ public class GroupByLevelNodeSerdeTest { new MeasurementPath("root.sg.d2.s1", TSDataType.INT32), Collections.singletonList( new AggregationDescriptor( - AggregationType.MAX_TIME, + AggregationType.MAX_TIME.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList( new TimeSeriesOperand(new PartialPath("root.sg.d2.s1"))))), @@ -83,7 +83,7 @@ public class GroupByLevelNodeSerdeTest { Arrays.asList(seriesAggregationScanNode1, seriesAggregationScanNode2), Collections.singletonList( new GroupByLevelDescriptor( - AggregationType.MAX_TIME, + AggregationType.MAX_TIME.name().toLowerCase(), AggregationStep.FINAL, Arrays.asList( new TimeSeriesOperand(new PartialPath("root.sg.d1.s1")), diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/source/SeriesAggregationScanNodeSerdeTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/source/SeriesAggregationScanNodeSerdeTest.java index 30631d98da..2eb810809b 100644 --- a/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/source/SeriesAggregationScanNodeSerdeTest.java +++ b/server/src/test/java/org/apache/iotdb/db/mpp/plan/plan/node/source/SeriesAggregationScanNodeSerdeTest.java @@ -51,7 +51,7 @@ public class SeriesAggregationScanNodeSerdeTest { List<AggregationDescriptor> aggregationDescriptorList = new ArrayList<>(); aggregationDescriptorList.add( new AggregationDescriptor( - AggregationType.MAX_TIME, + AggregationType.MAX_TIME.name().toLowerCase(), AggregationStep.FINAL, Collections.singletonList(new TimeSeriesOperand(new PartialPath("root.sg.d1.s1"))))); GroupByTimeParameter groupByTimeParameter =
