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
commit 9cc3468ca2228e081fd5c420b2a9216e5e3a062e Author: mch_ucchi <[email protected]> AuthorDate: Fri Mar 24 10:58:52 2023 +0800 [fix](planner) failed to create view when use window function (#17815) fix failed to create view when use window function because the view string contains slot id and which cannot be parsed. --- .../src/main/java/org/apache/doris/analysis/SelectStmt.java | 5 ++++- .../query_p0/sql_functions/window_functions/test_window_fn.groovy | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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 3a9507b414..b3fab0ccea 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 @@ -42,6 +42,7 @@ import org.apache.doris.common.TableAliasGenerator; import org.apache.doris.common.TreeNode; import org.apache.doris.common.UserException; import org.apache.doris.common.util.SqlUtils; +import org.apache.doris.common.util.ToSqlContext; import org.apache.doris.mysql.privilege.PrivPredicate; import org.apache.doris.qe.ConnectContext; import org.apache.doris.rewrite.ExprRewriter; @@ -1940,7 +1941,9 @@ public class SelectStmt extends QueryStmt { @Override public String toSql() { if (sqlString != null) { - return sqlString; + if (ToSqlContext.get() == null || ToSqlContext.get().isNeedSlotRefId()) { + return sqlString; + } } StringBuilder strBuilder = new StringBuilder(); if (withClause != null) { diff --git a/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy b/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy index 0e517f1d7e..c1842d730f 100644 --- a/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy +++ b/regression-test/suites/query_p0/sql_functions/window_functions/test_window_fn.groovy @@ -356,6 +356,14 @@ suite("test_window_fn") { from example_window_tb; """ + sql """ + create view v as select row_number() over(partition by u_city order by u_salary) as wf from example_window_tb + """ + + sql """ + drop view v + """ + sql "DROP TABLE IF EXISTS example_window_tb;" } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
