This is an automated email from the ASF dual-hosted git repository. weihao pushed a commit to branch lastAlias in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 2bf887380af6e83884eaa811d1ca9558b68e8581 Author: Weihao Li <[email protected]> AuthorDate: Thu Jan 29 09:14:03 2026 +0800 fix sort Signed-off-by: Weihao Li <[email protected]> --- .../db/queryengine/plan/planner/LogicalPlanBuilder.java | 15 ++++++++++----- .../plan/planner/plan/node/source/LastQueryScanNode.java | 10 ++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LogicalPlanBuilder.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LogicalPlanBuilder.java index 6bc348e530c..9e364a61147 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LogicalPlanBuilder.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/LogicalPlanBuilder.java @@ -253,11 +253,16 @@ public class LogicalPlanBuilder { for (Expression sourceExpression : measurementToExpressionsOfDevice.values()) { MeasurementPath selectedPath = (MeasurementPath) ((TimeSeriesOperand) sourceExpression).getPath(); - String outputPath = - sourceExpression.isViewExpression() - ? sourceExpression.getViewPath().getFullPath() - : null; - TSDataType outputViewPathType = outputPath == null ? null : selectedPath.getSeriesType(); + String outputPath; + TSDataType outputViewPathType = null; + // the path is view, use the view path as the output path + if (sourceExpression.isViewExpression()) { + outputPath = sourceExpression.getViewPath().getFullPath(); + outputViewPathType = selectedPath.getSeriesType(); + } else { + outputPath = selectedPath.getFullPath(); + } + // the path has alias, use alias as the output path if (selectedPath.isMeasurementAliasExists()) { outputPath = selectedPath diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/source/LastQueryScanNode.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/source/LastQueryScanNode.java index d6e0967ae51..6dd0d8199a8 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/source/LastQueryScanNode.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/source/LastQueryScanNode.java @@ -45,8 +45,6 @@ import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import static org.glassfish.jersey.internal.guava.Preconditions.checkState; - public class LastQueryScanNode extends LastSeriesSourceNode { private static final long INSTANCE_SIZE = @@ -193,12 +191,12 @@ public class LastQueryScanNode extends LastSeriesSourceNode { } public String getOutputSymbolForSort() { - if (isOutputPathForView) { - checkState( - outputPaths != null && outputPaths.size() == 1, - "LastQueryScanNode outputPaths size should be 1 when it's a viewPath"); + if (outputPaths != null && outputPaths.size() == 1) { return outputPaths.get(0); } + // If outputPaths is null or size > 1, it means there is no view and no alias, just return the + // device name is ok, + // because the measurements have been sorted in AnalyzeVisitor if needed. return devicePath.toString(); }
