This is an automated email from the ASF dual-hosted git repository.
panxiaolei 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 8249441335 [Bug](planner) add conjunct slotref id to table function
node to avoid result incorrect (#18063)
8249441335 is described below
commit 82494413358fd523b4c9c9503663d42c15e4399b
Author: Pxl <[email protected]>
AuthorDate: Fri Mar 24 14:48:03 2023 +0800
[Bug](planner) add conjunct slotref id to table function node to avoid
result incorrect (#18063)
add conjunct slotref id to table function node to avoid result incorrect
---
.../org/apache/doris/planner/TableFunctionNode.java | 11 +++++++++++
.../query_p0/sql_functions/table_function/explode.out | 17 +++++++++++++++++
.../sql_functions/table_function/explode.groovy | 19 +++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/TableFunctionNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/TableFunctionNode.java
index 92e1d7cdaf..80ca77da84 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/TableFunctionNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/TableFunctionNode.java
@@ -148,6 +148,17 @@ public class TableFunctionNode extends PlanNode {
public void init(Analyzer analyzer) throws UserException {
super.init(analyzer);
fnCallExprList = new ArrayList<>(lateralViewRefs.stream().map(e ->
e.getFnExpr()).collect(Collectors.toList()));
+ Set<SlotRef> outputSlotRef = Sets.newHashSet();
+ for (Expr expr : conjuncts) {
+ expr.getSlotRefsBoundByTupleIds(tupleIds, outputSlotRef);
+ Expr dst = outputSmap.get(expr);
+ if (dst != null) {
+ dst.getSlotRefsBoundByTupleIds(tupleIds, outputSlotRef);
+ }
+ }
+ for (SlotRef slotRef : outputSlotRef) {
+ outputSlotIds.add(slotRef.getSlotId());
+ }
/*
When the expression of the lateral view involves the column of the
subquery,
the column needs to be rewritten as the real column in the subquery
through childrenSmap.
diff --git
a/regression-test/data/query_p0/sql_functions/table_function/explode.out
b/regression-test/data/query_p0/sql_functions/table_function/explode.out
index 55bd9056c6..c3e327625a 100644
--- a/regression-test/data/query_p0/sql_functions/table_function/explode.out
+++ b/regression-test/data/query_p0/sql_functions/table_function/explode.out
@@ -29,3 +29,20 @@
1
\N
+-- !test1 --
+0
+1
+2
+3
+4
+
+-- !test2 --
+1
+
+-- !test3 --
+0 1
+1 1
+2 1
+3 1
+4 1
+
diff --git
a/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy
b/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy
index ebcee70ddf..7118ebf43b 100644
---
a/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy
+++
b/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy
@@ -30,4 +30,23 @@ suite("explode") {
// array with null elements
qt_explode """ select e1 from (select 1 k1) as t lateral view
explode([null,1,null]) tmp1 as e1; """
qt_explode_outer """ select e1 from (select 1 k1) as t lateral view
explode_outer([null,1,null]) tmp1 as e1; """
+
+ sql """ DROP TABLE IF EXISTS d_table; """
+ sql """
+ create table d_table(
+ k1 int null,
+ k2 int not null,
+ k3 bigint null,
+ k4 varchar(100) null
+ )
+ duplicate key (k1,k2,k3)
+ distributed BY hash(k1) buckets 3
+ properties("replication_num" = "1");
+ """
+
+ sql "insert into d_table select 1,1,1,'a';"
+
+ qt_test1 """select e1 from (select k1 from d_table) as t lateral view
explode_numbers(5) tmp1 as e1;"""
+ qt_test2 """select e1 from (select k1 from d_table) as t lateral view
explode_numbers(5) tmp1 as e1 where e1=k1;"""
+ qt_test3 """select e1,k1 from (select k1 from d_table) as t lateral view
explode_numbers(5) tmp1 as e1;"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]