This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 42a52d88999 [fix](planner) fix bug of select stmt toSql (#37274)
(#37346)
42a52d88999 is described below
commit 42a52d889994224a9bdf0cb105e314885f19bbca
Author: feiniaofeiafei <[email protected]>
AuthorDate: Mon Jul 8 19:40:12 2024 +0800
[fix](planner) fix bug of select stmt toSql (#37274) (#37346)
cherry-pick from master #37274
---
.../src/main/java/org/apache/doris/analysis/SelectStmt.java | 1 +
.../view_p0/create_view_star_except_and_cast_to_sql.out | 13 ++++++++-----
.../view_p0/create_view_star_except_and_cast_to_sql.groovy | 2 +-
3 files changed, 10 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 875e7b86357..01352d2ab10 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
@@ -553,6 +553,7 @@ public class SelectStmt extends QueryStmt {
// remove excepted columns
resultExprs.removeIf(expr ->
exceptCols.contains(expr.toColumnLabel()));
colLabels.removeIf(exceptCols::contains);
+ originalExpr = new ArrayList<>(resultExprs);
} else {
if (needToSql) {
originalExpr = new ArrayList<>();
diff --git
a/regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out
b/regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out
index 83628cb8356..7d14116acc5 100644
--- a/regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out
+++ b/regression-test/data/view_p0/create_view_star_except_and_cast_to_sql.out
@@ -1,10 +1,13 @@
-- This file is automatically generated. You should know what you did if you
want to edit this
-- !test_select_star_except --
-1 1
-2 1
-3 5
-4 5
-6 \N
+1 2
+2 3
+3 6
+4 6
+6 6
+
+-- !test_select_star_except_sql --
+v_mal_old_create_view CREATE VIEW `v_mal_old_create_view` AS SELECT
`default_cluster:regression_test_view_p0`.`mal_old_create_view`.`pk` AS `pk`,
`default_cluster:regression_test_view_p0`.`mal_old_create_view`.`b` AS `b` FROM
`default_cluster:regression_test_view_p0`.`mal_old_create_view`; utf8
utf8_general_ci
-- !test_sql --
v_mal_old_create_view2 CREATE VIEW `v_mal_old_create_view2` AS SELECT
CAST(CAST(`a` AS TEXT) AS TIME(0)) AS `CAST(CAST(``a`` AS TEXT) AS TIME(0))`
FROM `default_cluster:regression_test_view_p0`.`mal_old_create_view`;
utf8 utf8_general_ci
diff --git
a/regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy
b/regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy
index e22f929544b..56e47cc758e 100644
---
a/regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy
+++
b/regression-test/suites/view_p0/create_view_star_except_and_cast_to_sql.groovy
@@ -17,7 +17,6 @@
suite("create_view_star_except_and_cast_to_sql") {
sql "SET enable_nereids_planner=false;"
-
sql """
DROP TABLE IF EXISTS mal_old_create_view
"""
@@ -35,6 +34,7 @@ suite("create_view_star_except_and_cast_to_sql") {
sql "create view v_mal_old_create_view as select * except(a) from
mal_old_create_view"
qt_test_select_star_except "select * from v_mal_old_create_view order by
pk,b"
+ qt_test_select_star_except_sql "show create view v_mal_old_create_view"
sql "drop view if EXISTS v_mal_old_create_view2"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]