Skip to content

Commit

Permalink
[fix](planner) fix bug of select stmt toSql (apache#37274) (apache#37346
Browse files Browse the repository at this point in the history
)

cherry-pick from master apache#37274
  • Loading branch information
feiniaofeiafei authored and weixingyu12 committed Jul 24, 2024
1 parent 35f95f4 commit 842783b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ public void analyze(Analyzer analyzer) throws UserException {
// remove excepted columns
resultExprs.removeIf(expr -> exceptCols.contains(expr.toColumnLabel()));
colLabels.removeIf(exceptCols::contains);
originalExpr = new ArrayList<>(resultExprs);
} else {
if (needToSql) {
originalExpr = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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"

Expand Down

0 comments on commit 842783b

Please sign in to comment.