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

englefly 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 2e0e3c465d9 [refactor](nereids)unify outputTupleDesc and projection 
(#32093)
2e0e3c465d9 is described below

commit 2e0e3c465d9602e0c6d91e58ff3bd9cc15f4a035
Author: minghong <engle...@gmail.com>
AuthorDate: Fri Mar 22 18:34:19 2024 +0800

    [refactor](nereids)unify outputTupleDesc and projection (#32093)
    
    * unify join node output project
---
 .../apache/doris/job/extensions/mtmv/MTMVTask.java |  1 +
 .../glue/translator/PhysicalPlanTranslator.java    | 14 ++--
 .../org/apache/doris/planner/HashJoinNode.java     | 34 +++++-----
 .../org/apache/doris/planner/JoinNodeBase.java     | 78 +++++++++++-----------
 .../apache/doris/planner/NestedLoopJoinNode.java   | 30 ++++-----
 .../java/org/apache/doris/planner/PlanNode.java    | 16 +++--
 .../table_function/explode_json_array.groovy       | 32 +++++----
 7 files changed, 102 insertions(+), 103 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java 
b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
index d7722e090d0..499d1571d39 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
@@ -222,6 +222,7 @@ public class MTMVTask extends AbstractTask {
         executor = new StmtExecutor(ctx, new LogicalPlanAdapter(command, 
ctx.getStatementContext()));
         ctx.setExecutor(executor);
         ctx.setQueryId(queryId);
+        ctx.getState().setNereids(true);
         command.run(ctx, executor);
         if (ctx.getState().getStateType() != MysqlStateType.OK) {
             throw new JobException(ctx.getState().getErrorMessage());
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
index d9f1b4b2d5d..3d57564e5ee 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/PhysicalPlanTranslator.java
@@ -1336,6 +1336,7 @@ public class PhysicalPlanTranslator extends 
DefaultPlanVisitor<PlanFragment, Pla
                 null, null, null, hashJoin.isMarkJoin());
         hashJoinNode.setNereidsId(hashJoin.getId());
         hashJoinNode.setChildrenDistributeExprLists(distributeExprLists);
+        hashJoinNode.setUseSpecificProjections(false);
         PlanFragment currentFragment = connectJoinNode(hashJoinNode, 
leftFragment, rightFragment, context, hashJoin);
 
         if (JoinUtils.shouldColocateJoin(physicalHashJoin)) {
@@ -1563,8 +1564,8 @@ public class PhysicalPlanTranslator extends 
DefaultPlanVisitor<PlanFragment, Pla
             TupleDescriptor outputDescriptor = context.generateTupleDesc();
             outputSlotReferences.forEach(s -> 
context.createSlotDesc(outputDescriptor, s));
 
-            hashJoinNode.setvOutputTupleDesc(outputDescriptor);
-            hashJoinNode.setvSrcToOutputSMap(srcToOutput);
+            hashJoinNode.setOutputTupleDesc(outputDescriptor);
+            hashJoinNode.setProjectList(srcToOutput);
         }
         if (hashJoin.getStats() != null) {
             hashJoinNode.setCardinality((long) 
hashJoin.getStats().getRowCount());
@@ -1598,6 +1599,7 @@ public class PhysicalPlanTranslator extends 
DefaultPlanVisitor<PlanFragment, Pla
             NestedLoopJoinNode nestedLoopJoinNode = new 
NestedLoopJoinNode(context.nextPlanNodeId(),
                     leftFragmentPlanRoot, rightFragmentPlanRoot, tupleIds, 
JoinType.toJoinOperator(joinType),
                     null, null, null, nestedLoopJoin.isMarkJoin());
+            nestedLoopJoinNode.setUseSpecificProjections(false);
             nestedLoopJoinNode.setNereidsId(nestedLoopJoin.getId());
             
nestedLoopJoinNode.setChildrenDistributeExprLists(distributeExprLists);
             if (nestedLoopJoin.getStats() != null) {
@@ -1744,8 +1746,8 @@ public class PhysicalPlanTranslator extends 
DefaultPlanVisitor<PlanFragment, Pla
                 TupleDescriptor outputDescriptor = context.generateTupleDesc();
                 outputSlotReferences.forEach(s -> 
context.createSlotDesc(outputDescriptor, s));
 
-                nestedLoopJoinNode.setvOutputTupleDesc(outputDescriptor);
-                nestedLoopJoinNode.setvSrcToOutputSMap(srcToOutput);
+                nestedLoopJoinNode.setOutputTupleDesc(outputDescriptor);
+                nestedLoopJoinNode.setProjectList(srcToOutput);
             }
             if (nestedLoopJoin.getStats() != null) {
                 nestedLoopJoinNode.setCardinality((long) 
nestedLoopJoin.getStats().getRowCount());
@@ -1871,8 +1873,8 @@ public class PhysicalPlanTranslator extends 
DefaultPlanVisitor<PlanFragment, Pla
         if (inputPlanNode instanceof JoinNodeBase) {
             TupleDescriptor tupleDescriptor = generateTupleDesc(slots, null, 
context);
             JoinNodeBase joinNode = (JoinNodeBase) inputPlanNode;
-            joinNode.setvOutputTupleDesc(tupleDescriptor);
-            joinNode.setvSrcToOutputSMap(projectionExprs);
+            joinNode.setOutputTupleDesc(tupleDescriptor);
+            joinNode.setProjectList(projectionExprs);
             // prune the hashOutputSlotIds
             if (joinNode instanceof HashJoinNode) {
                 ((HashJoinNode) joinNode).getHashOutputSlotIds().clear();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
index d8cc4a77a0a..c3cbf2afce1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/HashJoinNode.java
@@ -171,7 +171,7 @@ public class HashJoinNode extends JoinNodeBase {
             nullableTupleIds.addAll(outer.getTupleIds());
         }
         vIntermediateTupleDescList = Lists.newArrayList(intermediateTuple);
-        vOutputTupleDesc = outputTuple;
+        this.outputTupleDesc = outputTuple;
         vSrcToOutputSMap = new ExprSubstitutionMap(srcToOutputList, 
Collections.emptyList());
     }
 
@@ -220,7 +220,7 @@ public class HashJoinNode extends JoinNodeBase {
             nullableTupleIds.addAll(outer.getTupleIds());
         }
         vIntermediateTupleDescList = Lists.newArrayList(intermediateTuple);
-        vOutputTupleDesc = outputTuple;
+        this.outputTupleDesc = outputTuple;
         vSrcToOutputSMap = new ExprSubstitutionMap(srcToOutputList, 
Collections.emptyList());
     }
 
@@ -800,26 +800,24 @@ public class HashJoinNode extends JoinNodeBase {
                 msg.hash_join_node.addToHashOutputSlotIds(slotId.asInt());
             }
         }
-        if (vSrcToOutputSMap != null) {
-            for (int i = 0; i < vSrcToOutputSMap.size(); i++) {
-                // TODO: Enable it after we support new optimizers
-                // if 
(ConnectContext.get().getSessionVariable().isEnableNereidsPlanner()) {
-                //     
msg.addToProjections(vSrcToOutputSMap.getLhs().get(i).treeToThrift());
-                // } else
-                
msg.hash_join_node.addToSrcExprList(vSrcToOutputSMap.getLhs().get(i).treeToThrift());
+        if (useSpecificProjections) {
+            if (vSrcToOutputSMap != null && vSrcToOutputSMap.getLhs() != null 
&& outputTupleDesc != null) {
+                for (int i = 0; i < vSrcToOutputSMap.size(); i++) {
+                    
msg.hash_join_node.addToSrcExprList(vSrcToOutputSMap.getLhs().get(i).treeToThrift());
+                }
+            }
+            if (outputTupleDesc != null) {
+                
msg.hash_join_node.setVoutputTupleId(outputTupleDesc.getId().asInt());
             }
         }
-        if (vOutputTupleDesc != null) {
-            
msg.hash_join_node.setVoutputTupleId(vOutputTupleDesc.getId().asInt());
-            // TODO Enable it after we support new optimizers
-            // msg.setOutputTupleId(vOutputTupleDesc.getId().asInt());
-        }
+
         if (vIntermediateTupleDescList != null) {
             for (TupleDescriptor tupleDescriptor : vIntermediateTupleDescList) 
{
                 
msg.hash_join_node.addToVintermediateTupleIdList(tupleDescriptor.getId().asInt());
             }
         }
         msg.hash_join_node.setDistType(isColocate ? 
TJoinDistributionType.COLOCATE : distrMode.toThrift());
+        msg.hash_join_node.setUseSpecificProjections(useSpecificProjections);
     }
 
     @Override
@@ -862,9 +860,11 @@ public class HashJoinNode extends JoinNodeBase {
             output.append(getRuntimeFilterExplainString(true));
         }
         output.append(detailPrefix).append(String.format("cardinality=%,d", 
cardinality)).append("\n");
-        // todo unify in plan node
-        if (vOutputTupleDesc != null) {
-            output.append(detailPrefix).append("vec output tuple id: 
").append(vOutputTupleDesc.getId()).append("\n");
+        if (outputTupleDesc != null) {
+            output.append(detailPrefix).append("vec output tuple id: 
").append(outputTupleDesc.getId()).append("\n");
+        }
+        if (outputTupleDesc != null) {
+            output.append(detailPrefix).append("output tuple id: 
").append(outputTupleDesc.getId()).append("\n");
         }
         if (vIntermediateTupleDescList != null) {
             output.append(detailPrefix).append("vIntermediate tuple ids: ");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java
index b635cfda59d..fbe12b3d6a0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/JoinNodeBase.java
@@ -44,7 +44,6 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -57,10 +56,14 @@ public abstract class JoinNodeBase extends PlanNode {
     protected final TableRef innerRef;
     protected final JoinOperator joinOp;
     protected final boolean isMark;
-    protected TupleDescriptor vOutputTupleDesc;
     protected ExprSubstitutionMap vSrcToOutputSMap;
     protected List<TupleDescriptor> vIntermediateTupleDescList;
 
+    // in thrift, every planNode denote its output tupelId and projections by 
output_tuple_id and projections
+    // but for legacy reasons, JoinNode has its specific representations: 
voutput_tuple_id and src_expr_list
+    // if useSpecificProjections true, set the output to its specific 
attributes.
+    protected boolean useSpecificProjections = true;
+
     public JoinNodeBase(PlanNodeId id, String planNodeName, StatisticalType 
statisticalType,
             PlanNode outer, PlanNode inner, TableRef innerRef) {
         super(id, planNodeName, statisticalType);
@@ -115,7 +118,7 @@ public abstract class JoinNodeBase extends PlanNode {
 
     protected void computeOutputTuple(Analyzer analyzer) throws UserException {
         // 1. create new tuple
-        vOutputTupleDesc = analyzer.getDescTbl().createTupleDescriptor();
+        outputTupleDesc = analyzer.getDescTbl().createTupleDescriptor();
         boolean copyLeft = false;
         boolean copyRight = false;
         boolean leftNullable = false;
@@ -169,7 +172,7 @@ public abstract class JoinNodeBase extends PlanNode {
                         getChild(0) instanceof JoinNodeBase && 
analyzer.isOuterJoined(leftTupleDesc.getId());
                 for (SlotDescriptor leftSlotDesc : leftTupleDesc.getSlots()) {
                     SlotDescriptor outputSlotDesc =
-                            
analyzer.getDescTbl().copySlotDescriptor(vOutputTupleDesc, leftSlotDesc);
+                            
analyzer.getDescTbl().copySlotDescriptor(outputTupleDesc, leftSlotDesc);
                     if (leftNullable) {
                         outputSlotDesc.setIsNullable(true);
                         leftNullableNumber++;
@@ -189,7 +192,7 @@ public abstract class JoinNodeBase extends PlanNode {
                         getChild(1) instanceof JoinNodeBase && 
analyzer.isOuterJoined(rightTupleDesc.getId());
                 for (SlotDescriptor rightSlotDesc : rightTupleDesc.getSlots()) 
{
                     SlotDescriptor outputSlotDesc =
-                            
analyzer.getDescTbl().copySlotDescriptor(vOutputTupleDesc, rightSlotDesc);
+                            
analyzer.getDescTbl().copySlotDescriptor(outputTupleDesc, rightSlotDesc);
                     if (rightNullable) {
                         outputSlotDesc.setIsNullable(true);
                         rightNullableNumber++;
@@ -206,7 +209,7 @@ public abstract class JoinNodeBase extends PlanNode {
         if (isMarkJoin() && analyzer.needPopUpMarkTuple(innerRef)) {
             SlotDescriptor markSlot = 
analyzer.getMarkTuple(innerRef).getSlots().get(0);
             SlotDescriptor outputSlotDesc =
-                    analyzer.getDescTbl().copySlotDescriptor(vOutputTupleDesc, 
markSlot);
+                    analyzer.getDescTbl().copySlotDescriptor(outputTupleDesc, 
markSlot);
             srcTblRefToOutputTupleSmap.put(new SlotRef(markSlot), new 
SlotRef(outputSlotDesc));
         }
 
@@ -224,7 +227,7 @@ public abstract class JoinNodeBase extends PlanNode {
             }
         }
 
-        vOutputTupleDesc.computeStatAndMemLayout();
+        outputTupleDesc.computeStatAndMemLayout();
         // 3. add tupleisnull in null-side
         Preconditions.checkState(srcTblRefToOutputTupleSmap.getLhs().size() == 
vSrcToOutputSMap.getLhs().size());
         // Condition1: the left child is null-side
@@ -265,8 +268,8 @@ public abstract class JoinNodeBase extends PlanNode {
     public void initOutputSlotIds(Set<SlotId> requiredSlotIdSet, Analyzer 
analyzer) {
         outputSlotIds = Lists.newArrayList();
         List<TupleDescriptor> outputTupleDescList = Lists.newArrayList();
-        if (vOutputTupleDesc != null) {
-            outputTupleDescList.add(vOutputTupleDesc);
+        if (outputTupleDesc != null) {
+            outputTupleDescList.add(outputTupleDesc);
         } else {
             for (TupleId tupleId : tupleIds) {
                 outputTupleDescList.add(analyzer.getTupleDesc(tupleId));
@@ -296,13 +299,13 @@ public abstract class JoinNodeBase extends PlanNode {
 
     @Override
     public void projectOutputTuple() {
-        if (vOutputTupleDesc == null) {
+        if (outputTupleDesc == null) {
             return;
         }
-        if (vOutputTupleDesc.getSlots().size() == outputSlotIds.size()) {
+        if (outputTupleDesc.getSlots().size() == outputSlotIds.size()) {
             return;
         }
-        Iterator<SlotDescriptor> iterator = 
vOutputTupleDesc.getSlots().iterator();
+        Iterator<SlotDescriptor> iterator = 
outputTupleDesc.getSlots().iterator();
         while (iterator.hasNext()) {
             SlotDescriptor slotDescriptor = iterator.next();
             boolean keep = false;
@@ -318,7 +321,7 @@ public abstract class JoinNodeBase extends PlanNode {
                 vSrcToOutputSMap.removeByRhsExpr(slotRef);
             }
         }
-        vOutputTupleDesc.computeStatAndMemLayout();
+        outputTupleDesc.computeStatAndMemLayout();
     }
 
     protected abstract Pair<Boolean, Boolean> needToCopyRightAndLeft();
@@ -404,14 +407,14 @@ public abstract class JoinNodeBase extends PlanNode {
         // 5. replace tuple is null expr
         
TupleIsNullPredicate.substitueListForTupleIsNull(vSrcToOutputSMap.getLhs(), 
originTidsToIntermediateTidMap);
 
-        Preconditions.checkState(vSrcToOutputSMap.getLhs().size() == 
vOutputTupleDesc.getSlots().size());
+        Preconditions.checkState(vSrcToOutputSMap.getLhs().size() == 
outputTupleDesc.getSlots().size());
         List<Expr> exprs = vSrcToOutputSMap.getLhs();
-        ArrayList<SlotDescriptor> slots = vOutputTupleDesc.getSlots();
+        ArrayList<SlotDescriptor> slots = outputTupleDesc.getSlots();
         for (int i = 0; i < slots.size(); i++) {
             slots.get(i).setIsNullable(exprs.get(i).isNullable());
         }
         vSrcToOutputSMap.reCalculateNullableInfoForSlotInRhs();
-        vOutputTupleDesc.computeMemLayout();
+        outputTupleDesc.computeMemLayout();
     }
 
     protected abstract List<SlotId> computeSlotIdsForJoinConjuncts(Analyzer 
analyzer);
@@ -479,7 +482,7 @@ public abstract class JoinNodeBase extends PlanNode {
     /**
      * If parent wants to get join node tupleids,
      * it will call this function instead of read properties directly.
-     * The reason is that the tuple id of vOutputTupleDesc the real output 
tuple id for join node.
+     * The reason is that the tuple id of outputTupleDesc the real output 
tuple id for join node.
      * <p>
      * If you read the properties of @tupleids directly instead of this 
function,
      * it reads the input id of the current node.
@@ -487,16 +490,16 @@ public abstract class JoinNodeBase extends PlanNode {
     @Override
     public ArrayList<TupleId> getTupleIds() {
         Preconditions.checkState(tupleIds != null);
-        if (vOutputTupleDesc != null) {
-            return Lists.newArrayList(vOutputTupleDesc.getId());
+        if (outputTupleDesc != null) {
+            return Lists.newArrayList(outputTupleDesc.getId());
         }
         return tupleIds;
     }
 
     @Override
     public ArrayList<TupleId> getOutputTblRefIds() {
-        if (vOutputTupleDesc != null) {
-            return Lists.newArrayList(vOutputTupleDesc.getId());
+        if (outputTupleDesc != null) {
+            return Lists.newArrayList(outputTupleDesc.getId());
         }
         switch (joinOp) {
             case LEFT_SEMI_JOIN:
@@ -513,8 +516,8 @@ public abstract class JoinNodeBase extends PlanNode {
 
     @Override
     public List<TupleId> getOutputTupleIds() {
-        if (vOutputTupleDesc != null) {
-            return Lists.newArrayList(vOutputTupleDesc.getId());
+        if (outputTupleDesc != null) {
+            return Lists.newArrayList(outputTupleDesc.getId());
         }
         switch (joinOp) {
             case LEFT_SEMI_JOIN:
@@ -544,13 +547,6 @@ public abstract class JoinNodeBase extends PlanNode {
         return Math.max(children.get(0).getNumInstances(), 
children.get(1).getNumInstances());
     }
 
-    /**
-     * Used by nereids.
-     */
-    public void setvOutputTupleDesc(TupleDescriptor vOutputTupleDesc) {
-        this.vOutputTupleDesc = vOutputTupleDesc;
-    }
-
     /**
      * Used by nereids.
      */
@@ -558,13 +554,6 @@ public abstract class JoinNodeBase extends PlanNode {
         this.vIntermediateTupleDescList = vIntermediateTupleDescList;
     }
 
-    /**
-     * Used by nereids.
-     */
-    public void setvSrcToOutputSMap(List<Expr> lhs) {
-        this.vSrcToOutputSMap = new ExprSubstitutionMap(lhs, 
Collections.emptyList());
-    }
-
     public void setOutputSmap(ExprSubstitutionMap smap, Analyzer analyzer) {
         outputSmap = smap;
         ExprSubstitutionMap tmpSmap = new 
ExprSubstitutionMap(Lists.newArrayList(vSrcToOutputSMap.getRhs()),
@@ -572,12 +561,12 @@ public abstract class JoinNodeBase extends PlanNode {
         List<Expr> newRhs = Lists.newArrayList();
         boolean bSmapChanged = false;
         for (Expr rhsExpr : smap.getRhs()) {
-            if (rhsExpr instanceof SlotRef || 
!rhsExpr.isBound(vOutputTupleDesc.getId())) {
+            if (rhsExpr instanceof SlotRef || 
!rhsExpr.isBound(outputTupleDesc.getId())) {
                 newRhs.add(rhsExpr);
             } else {
                 // we need do project in the join node
                 // add a new slot for projection result and add the project 
expr to vSrcToOutputSMap
-                SlotDescriptor slotDesc = 
analyzer.addSlotDescriptor(vOutputTupleDesc);
+                SlotDescriptor slotDesc = 
analyzer.addSlotDescriptor(outputTupleDesc);
                 slotDesc.initFromExpr(rhsExpr);
                 slotDesc.setIsMaterialized(true);
                 // the project expr is from smap, which use the slots of hash 
join node's output tuple
@@ -594,7 +583,16 @@ public abstract class JoinNodeBase extends PlanNode {
 
         if (bSmapChanged) {
             outputSmap.updateRhsExprs(newRhs);
-            vOutputTupleDesc.computeStatAndMemLayout();
+            outputTupleDesc.computeStatAndMemLayout();
         }
     }
+
+    public void setUseSpecificProjections(boolean useSpecificProjections) {
+        this.useSpecificProjections = useSpecificProjections;
+    }
+
+
+    public boolean isUseSpecificProjections() {
+        return useSpecificProjections;
+    }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java
index 9feac7e79ff..983cbfd5884 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java
@@ -127,7 +127,7 @@ public class NestedLoopJoinNode extends JoinNodeBase {
             nullableTupleIds.addAll(outer.getTupleIds());
         }
         vIntermediateTupleDescList = Lists.newArrayList(intermediateTuple);
-        vOutputTupleDesc = outputTuple;
+        outputTupleDesc = outputTuple;
         vSrcToOutputSMap = new ExprSubstitutionMap(srcToOutputList, 
Collections.emptyList());
     }
 
@@ -186,26 +186,25 @@ public class NestedLoopJoinNode extends JoinNodeBase {
         }
 
         msg.nested_loop_join_node.setIsMark(isMarkJoin());
-        if (vSrcToOutputSMap != null) {
-            for (int i = 0; i < vSrcToOutputSMap.size(); i++) {
-                // TODO: Enable it after we support new optimizers
-                // if 
(ConnectContext.get().getSessionVariable().isEnableNereidsPlanner()) {
-                //     
msg.addToProjections(vSrcToOutputSMap.getLhs().get(i).treeToThrift());
-                // } else
-                
msg.nested_loop_join_node.addToSrcExprList(vSrcToOutputSMap.getLhs().get(i).treeToThrift());
+
+        if (useSpecificProjections) {
+            if (vSrcToOutputSMap != null && vSrcToOutputSMap.getLhs() != null 
&& outputTupleDesc != null) {
+                for (int i = 0; i < vSrcToOutputSMap.size(); i++) {
+                    
msg.nested_loop_join_node.addToSrcExprList(vSrcToOutputSMap.getLhs().get(i).treeToThrift());
+                }
+            }
+            if (outputTupleDesc != null) {
+                
msg.nested_loop_join_node.setVoutputTupleId(outputTupleDesc.getId().asInt());
             }
         }
-        if (vOutputTupleDesc != null) {
-            
msg.nested_loop_join_node.setVoutputTupleId(vOutputTupleDesc.getId().asInt());
-            // TODO Enable it after we support new optimizers
-            // msg.setOutputTupleId(vOutputTupleDesc.getId().asInt());
-        }
+
         if (vIntermediateTupleDescList != null) {
             for (TupleDescriptor tupleDescriptor : vIntermediateTupleDescList) 
{
                 
msg.nested_loop_join_node.addToVintermediateTupleIdList(tupleDescriptor.getId().asInt());
             }
         }
         
msg.nested_loop_join_node.setIsOutputLeftSideOnly(isOutputLeftSideOnly);
+        
msg.nested_loop_join_node.setUseSpecificProjections(useSpecificProjections);
         msg.node_type = TPlanNodeType.CROSS_JOIN_NODE;
     }
 
@@ -258,10 +257,7 @@ public class NestedLoopJoinNode extends JoinNodeBase {
         }
         output.append(detailPrefix).append("is output left side only: 
").append(isOutputLeftSideOnly).append("\n");
         output.append(detailPrefix).append(String.format("cardinality=%,d", 
cardinality)).append("\n");
-        // todo unify in plan node
-        if (vOutputTupleDesc != null) {
-            output.append(detailPrefix).append("vec output tuple id: 
").append(vOutputTupleDesc.getId()).append("\n");
-        }
+
         if (vIntermediateTupleDescList != null) {
             output.append(detailPrefix).append("vIntermediate tuple ids: ");
             for (TupleDescriptor tupleDescriptor : vIntermediateTupleDescList) 
{
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
index ee8965c18a5..b404bc4ad35 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
@@ -648,13 +648,17 @@ public abstract class PlanNode extends TreeNode<PlanNode> 
implements PlanStats {
         }
         toThrift(msg);
         container.addToNodes(msg);
-        if (projectList != null) {
-            for (Expr expr : projectList) {
-                msg.addToProjections(expr.treeToThrift());
+
+        // legacy planner set outputTuple and projections inside join node
+        if (!(this instanceof JoinNodeBase) || !(((JoinNodeBase) 
this).isUseSpecificProjections())) {
+            if (outputTupleDesc != null) {
+                msg.setOutputTupleId(outputTupleDesc.getId().asInt());
+            }
+            if (projectList != null) {
+                for (Expr expr : projectList) {
+                    msg.addToProjections(expr.treeToThrift());
+                }
             }
-        }
-        if (outputTupleDesc != null) {
-            msg.setOutputTupleId(outputTupleDesc.getId().asInt());
         }
         if (this instanceof ExchangeNode) {
             msg.num_children = 0;
diff --git 
a/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
 
b/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
index e4cbe3feda0..e6ed1b62a24 100644
--- 
a/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
@@ -20,71 +20,69 @@
 // and modified by Doris.
 
 suite("explode_json_array") {
-    def tableName = "person"
-
-    sql """ DROP TABLE IF EXISTS ${tableName} """
+    sql """ DROP TABLE IF EXISTS person """
     sql """
-        CREATE TABLE IF NOT EXISTS ${tableName} 
+        CREATE TABLE IF NOT EXISTS person 
         (id INT, name STRING, age INT, class INT, address STRING) 
         UNIQUE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 8  
         PROPERTIES("replication_num" = "1")
     """
 
-    sql """ INSERT INTO ${tableName} VALUES
+    sql """ INSERT INTO person VALUES
         (100, 'John', 30, 1, 'Street 1'),
         (200, 'Mary', NULL, 1, 'Street 2'),
         (300, 'Mike', 80, 3, 'Street 3'),
         (400, 'Dan', 50, 4, 'Street 4')  """
-    qt_explode_json_array7 """ SELECT id, name, age, class, address, d_age, 
c_age FROM ${tableName}
+    qt_explode_json_array7 """ SELECT id, name, age, class, address, d_age, 
c_age FROM person
                         LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[30, 60]') t1 as 
c_age 
                         LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[40, 80]') t2 as 
d_age 
                         ORDER BY id, c_age, d_age """
 
-    qt_explode_json_array8 """ SELECT c_age, COUNT(1) FROM ${tableName}
+    qt_explode_json_array8 """ SELECT c_age, COUNT(1) FROM person
                         LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[30, 60]') t1 as 
c_age 
                         LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[40, 80]') t2 as 
d_age 
                         GROUP BY c_age ORDER BY c_age """
 
-    qt_explode_json_array_8_invalid """ SELECT c_age, COUNT(1) FROM 
${tableName}
+    qt_explode_json_array_8_invalid """ SELECT c_age, COUNT(1) FROM person
                         LATERAL VIEW EXPLODE_JSON_ARRAY_INT('["1", 60]') t1 as 
c_age 
                         LATERAL VIEW EXPLODE_JSON_ARRAY_INT('["b", "c"]') t2 
as d_age 
                         GROUP BY c_age ORDER BY c_age """
 
-    qt_explode_json_array9 """ SELECT * FROM ${tableName}
+    qt_explode_json_array9 """ SELECT * FROM person
                             LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[]') t1 AS 
c_age 
                             ORDER BY id, c_age """
 
-    qt_explode_json_array10 """ SELECT id, name, age, class, address, d, c 
FROM ${tableName}
+    qt_explode_json_array10 """ SELECT id, name, age, class, address, d, c 
FROM person
                         LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[1, "b", -3]') 
t1 as c 
                         LATERAL VIEW EXPLODE_JSON_ARRAY_DOUBLE('[1.23, 22.214, 
214.1]') t2 as d 
                         ORDER BY id, c, d """
 
     qt_outer_join_explode_json_array11 """SELECT id, age, e1 FROM (SELECT id, 
age, e1 FROM (SELECT b.id, a.age FROM 
-                                        ${tableName} a LEFT JOIN ${tableName} 
b ON a.id=b.age)T LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[1, "b", 3]')
+                                        person a LEFT JOIN person b ON 
a.id=b.age)T LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[1, "b", 3]')
                                         TMP AS e1) AS T ORDER BY age, e1"""
     qt_outer_join_explode_json_array11 """SELECT id, age, e1 FROM (SELECT id, 
age, e1 FROM (SELECT b.id, a.age FROM
-                                        ${tableName} a LEFT JOIN ${tableName} 
b ON a.id=b.age)T LATERAL VIEW 
EXPLODE_JSON_ARRAY_JSON('[{"id":1,"name":"John"},{"id":2,"name":"Mary"},{"id":3,"name":"Bob"}]')
+                                        person a LEFT JOIN person b ON 
a.id=b.age)T LATERAL VIEW 
EXPLODE_JSON_ARRAY_JSON('[{"id":1,"name":"John"},{"id":2,"name":"Mary"},{"id":3,"name":"Bob"}]')
                                         TMP AS e1) AS T ORDER BY age, e1"""
 
-    qt_explode_json_array12 """ SELECT c_age, COUNT(1) FROM ${tableName}
+    qt_explode_json_array12 """ SELECT c_age, COUNT(1) FROM person
                         LATERAL VIEW 
EXPLODE_JSON_ARRAY_INT('[9223372036854775807,9223372036854775808]') t1 as c_age 
                         GROUP BY c_age ORDER BY c_age """
 
-    qt_explode_json_array13 """ SELECT c_age, COUNT(1) FROM ${tableName}
+    qt_explode_json_array13 """ SELECT c_age, COUNT(1) FROM person
                         LATERAL VIEW 
EXPLODE_JSON_ARRAY_INT('[-92233720368547758071,-92233720368547758081]') t1 as 
c_age 
                         GROUP BY c_age ORDER BY c_age """
 
-    qt_explode_json_array14 """ SELECT id, name, age, class, address, d, c 
FROM ${tableName}
+    qt_explode_json_array14 """ SELECT id, name, age, class, address, d, c 
FROM person
                         LATERAL VIEW 
EXPLODE_JSON_ARRAY_STRING('[1182381637816312, "b", -1273982982312333]') t1 as c 
                         LATERAL VIEW EXPLODE_JSON_ARRAY_DOUBLE('[1.23, 22.214, 
214.1]') t2 as d 
                         ORDER BY id, c, d """
 
-    qt_explode_json_array15 """ SELECT id, name, age, class, address, d, c 
FROM ${tableName}
+    qt_explode_json_array15 """ SELECT id, name, age, class, address, d, c 
FROM person
                         LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[true, "b", 
false]') t1 as c 
                         LATERAL VIEW EXPLODE_JSON_ARRAY_DOUBLE('[1.23, 22.214, 
214.1]') t2 as d 
                         ORDER BY id, c, d """    
 
-    qt_explode_json_array16 """ SELECT id, name, age, class, address, d, c 
FROM ${tableName}
+    qt_explode_json_array16 """ SELECT id, name, age, class, address, d, c 
FROM person
                         LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[null, "b", 
null]') t1 as c 
                         LATERAL VIEW EXPLODE_JSON_ARRAY_DOUBLE('[1.23, 22.214, 
214.1]') t2 as d 
                         ORDER BY id, c, d """        


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

Reply via email to