Skip to content

Commit

Permalink
Pick "[fix](planner) failed to create view when use window function (a…
Browse files Browse the repository at this point in the history
…pache#17815)" (apache#1592)

fix failed to create view when use window function because the view string contains slot id and which cannot be parsed.

Co-authored-by: mch_ucchi <41606806+sohardforaname@users.noreply.github.com>
  • Loading branch information
luwei16 and sohardforaname authored Apr 4, 2023
1 parent ec5a362 commit d6d2790
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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;
Expand Down Expand Up @@ -1950,7 +1951,9 @@ private boolean checkSortNodeEliminable(Expr expr, List<SlotRef> sortSlotRefs) {
@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;"
}

Expand Down

0 comments on commit d6d2790

Please sign in to comment.