Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: function name in ErrWindowInvalidWindowFuncUse should be lowercase #11520

Merged
merged 3 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion planner/core/expression_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (er *expressionRewriter) Enter(inNode ast.Node) (ast.Node, bool) {
index, ok = er.windowMap[v]
}
if !ok {
er.err = ErrWindowInvalidWindowFuncUse.GenWithStackByArgs(v.F)
er.err = ErrWindowInvalidWindowFuncUse.GenWithStackByArgs(strings.ToLower(v.F))
return inNode, true
}
er.ctxStack = append(er.ctxStack, er.schema.Columns[index])
Expand Down
2 changes: 1 addition & 1 deletion planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ func (a *havingWindowAndOrderbyExprResolver) Leave(n ast.Node) (node ast.Node, o
case *ast.WindowFuncExpr:
a.inWindowFunc = false
if a.curClause == havingClause {
a.err = ErrWindowInvalidWindowFuncUse.GenWithStackByArgs(v.F)
a.err = ErrWindowInvalidWindowFuncUse.GenWithStackByArgs(strings.ToLower(v.F))
return node, false
}
if a.curClause == orderByClause {
Expand Down
8 changes: 8 additions & 0 deletions planner/core/logical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,14 @@ func (s *testPlanSuite) TestWindowFunction(c *C) {
sql: "delete from t order by (sum(a) over())",
result: "[planner:3593]You cannot use the window function 'sum' in this context.'",
},
{
sql: "delete from t order by (SUM(a) over())",
result: "[planner:3593]You cannot use the window function 'sum' in this context.'",
},
{
sql: "SELECT * from t having ROW_NUMBER() over()",
result: "[planner:3593]You cannot use the window function 'row_number' in this context.'",
},
{
// The best execution order should be (a,c), (a, b, c), (a, b), (), it requires only 2 sort operations.
sql: "select sum(a) over (partition by a order by b), sum(b) over (order by a, b, c), sum(c) over(partition by a order by c), sum(d) over() from t",
Expand Down