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 29c03db6f2 [fix](planner) table valued function could not used in
subquery (#15495)
29c03db6f2 is described below
commit 29c03db6f2e811a4f13e054c6c87b5b05c5fac62
Author: morrySnow <[email protected]>
AuthorDate: Fri Dec 30 09:57:52 2022 +0800
[fix](planner) table valued function could not used in subquery (#15495)
cherry-pick #15496
---
.../src/main/java/org/apache/doris/analysis/SelectStmt.java | 1 -
.../java/org/apache/doris/analysis/TableValuedFunctionRef.java | 8 +++-----
.../data/correctness_p0/table_valued_function/test_numbers.out | 10 ++++++++++
.../correctness_p0/table_valued_function/test_numbers.groovy | 4 ++++
4 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 26a0eb5e8b..1af417841a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -304,7 +304,6 @@ public class SelectStmt extends QueryStmt {
inlineStmt.getTables(analyzer, expandView, tableMap,
parentViewNameSet);
} else if (tblRef instanceof TableValuedFunctionRef) {
TableValuedFunctionRef tblFuncRef = (TableValuedFunctionRef)
tblRef;
- tblFuncRef.analyze(analyzer);
tableMap.put(tblFuncRef.getTableFunction().getTable().getId(),
tblFuncRef.getTableFunction().getTable());
} else {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableValuedFunctionRef.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableValuedFunctionRef.java
index 2bbf5e00be..4871baf889 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/TableValuedFunctionRef.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/TableValuedFunctionRef.java
@@ -32,10 +32,12 @@ public class TableValuedFunctionRef extends TableRef {
private String funcName;
private Map<String, String> params;
- public TableValuedFunctionRef(String funcName, String alias, Map<String,
String> params) {
+ public TableValuedFunctionRef(String funcName, String alias, Map<String,
String> params) throws AnalysisException {
super(new TableName(null, null, "_table_valued_function_" + funcName),
alias);
this.funcName = funcName;
this.params = params;
+ this.tableFunction = TableValuedFunctionIf.getTableFunction(funcName,
params);
+ this.table = tableFunction.getTable();
if (hasExplicitAlias()) {
return;
}
@@ -70,10 +72,6 @@ public class TableValuedFunctionRef extends TableRef {
if (isAnalyzed) {
return;
}
- // Table function could generate a table which will has columns
- // Maybe will call be during this process
- this.tableFunction = TableValuedFunctionIf.getTableFunction(funcName,
params);
- this.table = tableFunction.getTable();
desc = analyzer.registerTableRef(this);
isAnalyzed = true; // true that we have assigned desc
analyzeJoin(analyzer);
diff --git
a/regression-test/data/correctness_p0/table_valued_function/test_numbers.out
b/regression-test/data/correctness_p0/table_valued_function/test_numbers.out
index 9194eba1e6..ef65f7eea5 100644
--- a/regression-test/data/correctness_p0/table_valued_function/test_numbers.out
+++ b/regression-test/data/correctness_p0/table_valued_function/test_numbers.out
@@ -806,3 +806,13 @@ true
28 (
29 )
+-- !subquery_1 --
+0
+1
+2
+
+-- !subquery_2 --
+0 0 1
+1 0 1
+2 0 1
+
diff --git
a/regression-test/suites/correctness_p0/table_valued_function/test_numbers.groovy
b/regression-test/suites/correctness_p0/table_valued_function/test_numbers.groovy
index fd2bc9b444..f7647b178d 100644
---
a/regression-test/suites/correctness_p0/table_valued_function/test_numbers.groovy
+++
b/regression-test/suites/correctness_p0/table_valued_function/test_numbers.groovy
@@ -119,4 +119,8 @@
qt_stringfunction_28 """ select substring(cast (number as string),2) as
string_fucntion_res from numbers("number" = "1000") where number>105 limit 10;
"""
qt_stringfunction_29 """ select substring(cast (number as string),-1) as
string_fucntion_res from numbers("number" = "1000") where number>105 limit 10;
"""
qt_stringfunction_30 """ select number,unhex(cast (number as string)) as
string_fucntion_res from numbers("number" = "100") limit 30; """
+
+ // test subquery
+ order_qt_subquery_1 """ with a as (select number from
numbers("number"="3")) select * from a; """
+ order_qt_subquery_2 """ select * from (select number from
numbers("number"="3")) a join (select * from (select number from
numbers("number"="1")) a join (select 1) b) b; """
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]