This is an automated email from the ASF dual-hosted git repository.

jackietien pushed a commit to branch IOTDB-4151
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 3196c3ff76523e4c5559828c1b7402d9da449f05
Author: JackieTien97 <[email protected]>
AuthorDate: Wed Aug 17 10:09:05 2022 +0800

    Fix IndexOutOfBound Error in last query
---
 .../org/apache/iotdb/db/mpp/plan/planner/OperatorTreeGenerator.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/OperatorTreeGenerator.java
 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/OperatorTreeGenerator.java
index 5c4570a1fe..214d024741 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/OperatorTreeGenerator.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/OperatorTreeGenerator.java
@@ -1586,9 +1586,11 @@ public class OperatorTreeGenerator extends 
PlanVisitor<Operator, LocalExecutionP
                 node.getPlanNodeId(),
                 TimeJoinOperator.class.getSimpleName());
 
-    SortItem item = node.getMergeOrderParameter().getSortItemList().get(0);
+    List<SortItem> items = node.getMergeOrderParameter().getSortItemList();
     Comparator<Binary> comparator =
-        item.getOrdering() == Ordering.ASC ? ASC_BINARY_COMPARATOR : 
DESC_BINARY_COMPARATOR;
+        (items.isEmpty() || items.get(0).getOrdering() == Ordering.ASC)
+            ? ASC_BINARY_COMPARATOR
+            : DESC_BINARY_COMPARATOR;
 
     context.getTimeSliceAllocator().recordExecutionWeight(operatorContext, 1);
     return new LastQueryMergeOperator(operatorContext, children, comparator);

Reply via email to