Skip to content

Commit

Permalink
planner: fix redundant brackets cause full group by check fail… (ping…
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHuaiyu authored Apr 4, 2020
1 parent 46485b6 commit 43c2a35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,16 @@ func (s *testSuite1) TestIssue13652(c *C) {
c.Assert(err.Error(), Equals, "[planner:1055]Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.t.a' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by")
}

func (s *testSuite1) TestIssue14947(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("set sql_mode = 'ONLY_FULL_GROUP_BY'")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")
tk.MustQuery("select ((+a+1)) as tmp from t group by tmp")
tk.MustQuery("select count(*), (case when a=1 then 0 else 2 end) as xx from t group by xx;")
}

func (s *testSuite1) TestHaving(c *C) {
tk := testkit.NewTestKitWithInit(c, s.store)

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 @@ -1754,7 +1754,7 @@ func (b *PlanBuilder) checkOnlyFullGroupByWithGroupClause(p LogicalPlan, sel *as
if field.Auxiliary {
continue
}
checkExprInGroupBy(p, field.Expr, offset, ErrExprInSelect, gbyCols, gbyExprs, notInGbyCols)
checkExprInGroupBy(p, getInnerFromParenthesesAndUnaryPlus(field.Expr), offset, ErrExprInSelect, gbyCols, gbyExprs, notInGbyCols)
}

if sel.OrderBy != nil {
Expand Down

0 comments on commit 43c2a35

Please sign in to comment.