From 624db42e2f8b114d018924ba60e2586c62ec0590 Mon Sep 17 00:00:00 2001 From: time-and-fate <25057648+time-and-fate@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:57:30 +0800 Subject: [PATCH] planner: fix different err msg from MySQL when groupby window function --- planner/core/logical_plan_builder.go | 4 ++++ planner/core/logical_plan_test.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/planner/core/logical_plan_builder.go b/planner/core/logical_plan_builder.go index 777b7a08d97db..8435bf42de9b5 100644 --- a/planner/core/logical_plan_builder.go +++ b/planner/core/logical_plan_builder.go @@ -1733,6 +1733,10 @@ func (g *gbyResolver) Leave(inNode ast.Node) (ast.Node, bool) { g.err = ErrWrongGroupField.GenWithStackByArgs(g.fields[pos-1].Text()) return inNode, false } + if _, ok := ret.(*ast.WindowFuncExpr); ok { + g.err = ErrWrongGroupField.GenWithStackByArgs(g.fields[pos-1].Text()) + return inNode, false + } return ret, true case *ast.ValuesExpr: if v.Column == nil { diff --git a/planner/core/logical_plan_test.go b/planner/core/logical_plan_test.go index 02757eac9b4e2..2e127fc1f001c 100644 --- a/planner/core/logical_plan_test.go +++ b/planner/core/logical_plan_test.go @@ -1221,7 +1221,8 @@ func (s *testPlanSuite) TestNameResolver(c *C) { {"delete a from (select * from t ) as a, t", "[planner:1288]The target table a of the DELETE is not updatable"}, {"delete b from (select * from t ) as a, t", "[planner:1109]Unknown table 'b' in MULTI DELETE"}, {"select '' as fakeCol from t group by values(fakeCol)", "[planner:1054]Unknown column '' in 'VALUES() function'"}, - {"update t, (select * from t) as b set b.a = t.a", "[planner:1288]The target table b of the UPDATE is not updatable"}, + {"update t, (select * from ht) as b set b.a = t.a", "[planner:1288]The target table b of the UPDATE is not updatable"}, + {"select row_number() over () from t group by 1", "[planner:1056]Can't group on 'row_number() over ()'"}, } ctx := context.Background()