Skip to content

Commit

Permalink
planner: function name in ErrWindowInvalidWindowFuncUse should be l…
Browse files Browse the repository at this point in the history
…owercase
  • Loading branch information
zhaoyanxing authored and SunRunAway committed Jul 31, 2019
1 parent ab45834 commit 1913237
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
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

0 comments on commit 1913237

Please sign in to comment.