This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new e829061614 [fix](sort)should not change resolvedTupleExprs in toThrift method (#13211) e829061614 is described below commit e829061614eb4145faeafb3748c720671c542de6 Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Mon Oct 10 08:39:58 2022 +0800 [fix](sort)should not change resolvedTupleExprs in toThrift method (#13211) The toThrift method will be called mutilple times for sending data to different be but the changes of resolvedTupleExprs should be done only once. This pr make sure the resolvedTupleExprs can only be changed only once --- .../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 d1218e6191..1012f3bb3f 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 @@ -69,6 +69,8 @@ public class SortNode extends PlanNode { private boolean isAnalyticSort; private DataPartition inputPartition; + private boolean isUnusedExprRemoved = false; + /** * Constructor. */ @@ -241,19 +243,28 @@ 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 protected void toThrift(TPlanNode msg) { msg.node_type = TPlanNodeType.SORT_NODE; TSortInfo sortInfo = info.toThrift(); 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)); } TSortNode sortNode = new TSortNode(sortInfo, useTopN); @@ -280,13 +291,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); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org