diff --git a/planner/core/expression_rewriter.go b/planner/core/expression_rewriter.go index 3d0b48cb32897..ee07adf4f9401 100644 --- a/planner/core/expression_rewriter.go +++ b/planner/core/expression_rewriter.go @@ -322,7 +322,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]) diff --git a/planner/core/logical_plan_builder.go b/planner/core/logical_plan_builder.go index 15d259f6ed60b..72549fef0448a 100644 --- a/planner/core/logical_plan_builder.go +++ b/planner/core/logical_plan_builder.go @@ -1240,7 +1240,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 { diff --git a/planner/core/logical_plan_test.go b/planner/core/logical_plan_test.go index dd83b98ae48f1..dfba5b4cc54dc 100644 --- a/planner/core/logical_plan_test.go +++ b/planner/core/logical_plan_test.go @@ -2327,6 +2327,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",