diff --git a/planner/core/logical_plan_builder.go b/planner/core/logical_plan_builder.go index 2c7bf7c5572e1..bb4fbb9306c88 100644 --- a/planner/core/logical_plan_builder.go +++ b/planner/core/logical_plan_builder.go @@ -3148,7 +3148,7 @@ func (b *PlanBuilder) buildWindowFunctions(p LogicalPlan, groupedFuncs map[*ast. return nil, nil, err } if desc == nil { - return nil, nil, ErrWrongArguments.GenWithStackByArgs(windowFunc.F) + return nil, nil, ErrWrongArguments.GenWithStackByArgs(strings.ToLower(windowFunc.F)) } preArgs += len(windowFunc.Args) desc.WrapCastForAggArgs(b.ctx) diff --git a/planner/core/logical_plan_test.go b/planner/core/logical_plan_test.go index 702a3f7d1a5d4..af720722fc48b 100644 --- a/planner/core/logical_plan_test.go +++ b/planner/core/logical_plan_test.go @@ -2281,6 +2281,10 @@ func (s *testPlanSuite) TestWindowFunction(c *C) { sql: "select nth_value(a, 1.0) over() from t", result: "[planner:1210]Incorrect arguments to nth_value", }, + { + sql: "SELECT NTH_VALUE(a, 1.0) OVER() FROM t", + result: "[planner:1210]Incorrect arguments to nth_value", + }, { sql: "select nth_value(a, 0) over() from t", result: "[planner:1210]Incorrect arguments to nth_value",