Skip to content

Commit

Permalink
planner: fix redundant brackets cause full group by check failed (pin…
Browse files Browse the repository at this point in the history
  • Loading branch information
lzmhhh123 authored Feb 28, 2020
1 parent 6a94266 commit caf18df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions executor/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,15 @@ func (s *testSuiteAgg) 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 *testSuiteAgg) 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")
}

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

if sel.OrderBy != nil {
Expand Down

0 comments on commit caf18df

Please sign in to comment.