This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new db32b251e6 [fix](fe)project should be done inside subquery (#17716)
db32b251e6 is described below
commit db32b251e6a9c3b8307484803af34a0868093e25
Author: starocean999 <[email protected]>
AuthorDate: Mon Mar 13 11:48:53 2023 +0800
[fix](fe)project should be done inside subquery (#17716)
pick from master #17630
---
.../apache/doris/planner/NestedLoopJoinNode.java | 4 +--
.../org/apache/doris/planner/OlapScanNode.java | 42 ++++++++++++++++++++++
.../java/org/apache/doris/planner/SelectNode.java | 3 +-
.../query_p0/group_concat/test_group_concat.out | 1 -
4 files changed, 46 insertions(+), 4 deletions(-)
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 4f4f0dfded..421c534860 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
@@ -70,8 +70,8 @@ public class NestedLoopJoinNode extends JoinNodeBase {
public NestedLoopJoinNode(PlanNodeId id, PlanNode outer, PlanNode inner,
TableRef innerRef) {
super(id, "NESTED LOOP JOIN", StatisticalType.NESTED_LOOP_JOIN_NODE,
outer, inner, innerRef);
- tupleIds.addAll(outer.getTupleIds());
- tupleIds.addAll(inner.getTupleIds());
+ tupleIds.addAll(outer.getOutputTupleIds());
+ tupleIds.addAll(inner.getOutputTupleIds());
}
public boolean canParallelize() {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
index 14577c1967..582aef8de5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
@@ -22,6 +22,7 @@ import org.apache.doris.analysis.BaseTableRef;
import org.apache.doris.analysis.BinaryPredicate;
import org.apache.doris.analysis.CastExpr;
import org.apache.doris.analysis.Expr;
+import org.apache.doris.analysis.ExprSubstitutionMap;
import org.apache.doris.analysis.InPredicate;
import org.apache.doris.analysis.IntLiteral;
import org.apache.doris.analysis.PartitionNames;
@@ -1243,4 +1244,45 @@ public class OlapScanNode extends ScanNode {
public String getSelectedIndexName() {
return olapTable.getIndexNameById(selectedIndexId);
}
+
+ public void setOutputSmap(ExprSubstitutionMap smap, Analyzer analyzer) {
+ if (smap.getRhs().stream().anyMatch(expr -> !(expr instanceof
SlotRef))) {
+ if (outputTupleDesc == null) {
+ outputTupleDesc =
analyzer.getDescTbl().createTupleDescriptor("OlapScanNode");
+ outputTupleDesc.setTable(this.olapTable);
+ }
+ if (projectList == null) {
+ projectList = Lists.newArrayList();
+ }
+ List<Expr> newRhs = Lists.newArrayList();
+ List<Expr> newLhs = Lists.newArrayList();
+ for (Expr expr : smap.getRhs()) {
+ if (expr instanceof SlotRef && !((SlotRef)
expr).getDesc().isMaterialized()) {
+ continue;
+ }
+ if (outputSmap.mappingForRhsExpr(expr) != null) {
+ newLhs.add(outputSmap.mappingForRhsExpr(expr));
+ newRhs.add(expr);
+ } else {
+ SlotDescriptor slotDesc =
analyzer.addSlotDescriptor(outputTupleDesc);
+ slotDesc.initFromExpr(expr);
+ slotDesc.setIsMaterialized(true);
+ slotDesc.materializeSrcExpr();
+ projectList.add(expr);
+ newLhs.add(smap.mappingForRhsExpr(expr));
+ newRhs.add(new SlotRef(slotDesc));
+ }
+ }
+ outputSmap = new ExprSubstitutionMap(newLhs, newRhs);
+ } else {
+ outputSmap = smap;
+ }
+ }
+
+ public List<TupleId> getOutputTupleIds() {
+ if (outputTupleDesc != null) {
+ return Lists.newArrayList(outputTupleDesc.getId());
+ }
+ return tupleIds;
+ }
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/SelectNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/SelectNode.java
index 2baa6e6f13..6d78b5cb48 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/SelectNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/SelectNode.java
@@ -32,6 +32,7 @@ import org.apache.doris.thrift.TPlanNodeType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -41,7 +42,7 @@ public class SelectNode extends PlanNode {
private static final Logger LOG = LogManager.getLogger(SelectNode.class);
protected SelectNode(PlanNodeId id, PlanNode child, List<Expr> conjuncts) {
- super(id, child.getTupleIds(), "SELECT", StatisticalType.SELECT_NODE);
+ super(id, new ArrayList<>(child.getOutputTupleIds()), "SELECT",
StatisticalType.SELECT_NODE);
addChild(child);
this.tblRefIds = child.tblRefIds;
this.nullableTupleIds = child.nullableTupleIds;
diff --git a/regression-test/data/query_p0/group_concat/test_group_concat.out
b/regression-test/data/query_p0/group_concat/test_group_concat.out
index 8caca13a7e..e61bd4fd4f 100644
--- a/regression-test/data/query_p0/group_concat/test_group_concat.out
+++ b/regression-test/data/query_p0/group_concat/test_group_concat.out
@@ -25,4 +25,3 @@ false
25699 1989
2147483647 255:1991:32767:32767
-
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]