Skip to content

Commit

Permalink
planner: fix different err msg from MySQL when group by window functi…
Browse files Browse the repository at this point in the history
  • Loading branch information
time-and-fate authored and sre-bot committed Apr 8, 2020
1 parent a153f19 commit 1b59090
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,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 {
Expand Down
3 changes: 2 additions & 1 deletion planner/core/logical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2120,7 +2120,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()
Expand Down

0 comments on commit 1b59090

Please sign in to comment.