You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/10/12 01:04:49 UTC

[doris] branch branch-1.1-lts updated: [fix](sort)should not change resolvedTupleExprs in toThrift method (#13300)

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

yiguolei pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
     new c142c2baae [fix](sort)should not change resolvedTupleExprs in toThrift method (#13300)
c142c2baae is described below

commit c142c2baaee392451c2e3be4dd7250cf7f28a883
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Wed Oct 12 09:04:43 2022 +0800

    [fix](sort)should not change resolvedTupleExprs in toThrift method (#13300)
---
 .../java/org/apache/doris/planner/SortNode.java    | 30 +++++++++++++---------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/SortNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/SortNode.java
index 18a81741a5..c6d5bf2332 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SortNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SortNode.java
@@ -64,6 +64,8 @@ public class SortNode extends PlanNode {
     // info_.sortTupleSlotExprs_ substituted with the outputSmap_ for materialized slots in init().
     List<Expr> resolvedTupleExprs;
 
+    private boolean isUnusedExprRemoved = false;
+
     public void setIsAnalyticSort(boolean v) {
         isAnalyticSort = v;
     }
@@ -122,6 +124,20 @@ public class SortNode extends PlanNode {
         Expr.getIds(info.getOrderingExprs(), null, ids);
     }
 
+    private void removeUnusedExprs() {
+        if (!isUnusedExprRemoved) {
+            if (resolvedTupleExprs != null) {
+                List<SlotDescriptor> slotDescriptorList = this.info.getSortTupleDescriptor().getSlots();
+                for (int i = slotDescriptorList.size() - 1; i >= 0; i--) {
+                    if (!slotDescriptorList.get(i).isMaterialized()) {
+                        resolvedTupleExprs.remove(i);
+                    }
+                }
+            }
+            isUnusedExprRemoved = true;
+        }
+    }
+
     @Override
     public void setCompactData(boolean on) {
         this.compactData = on;
@@ -156,13 +172,8 @@ public class SortNode extends PlanNode {
 
     @Override
     public Set<SlotId> computeInputSlotIds(Analyzer analyzer) throws NotImplementedException {
-        List<SlotDescriptor> slotDescriptorList = this.info.getSortTupleDescriptor().getSlots();
+        removeUnusedExprs();
         List<Expr> materializedTupleExprs = new ArrayList<>(resolvedTupleExprs);
-        for (int i = slotDescriptorList.size() - 1; i >= 0; i--) {
-            if (!slotDescriptorList.get(i).isMaterialized()) {
-                materializedTupleExprs.remove(i);
-            }
-        }
         List<SlotId> result = Lists.newArrayList();
         Expr.getIds(materializedTupleExprs, null, result);
         return new HashSet<>(result);
@@ -187,13 +198,8 @@ public class SortNode extends PlanNode {
                 info.getIsAscOrder(),
                 info.getNullsFirst());
         Preconditions.checkState(tupleIds.size() == 1, "Incorrect size for tupleIds in SortNode");
+        removeUnusedExprs();
         if (resolvedTupleExprs != null) {
-            List<SlotDescriptor> slotDescriptorList = this.info.getSortTupleDescriptor().getSlots();
-            for (int i = slotDescriptorList.size() - 1; i >= 0; i--) {
-                if (!slotDescriptorList.get(i).isMaterialized()) {
-                    resolvedTupleExprs.remove(i);
-                }
-            }
             sortInfo.setSortTupleSlotExprs(Expr.treesToThrift(resolvedTupleExprs));
         }
         


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org