Skip to content

Commit

Permalink
planner: fix false negative "full group by" check for agg in subquery (
Browse files Browse the repository at this point in the history
  • Loading branch information
eurekaka committed Mar 5, 2019
1 parent 3d40d25 commit 24c9b99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions planner/core/expression_rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,18 @@ func (s *testExpressionRewriterSuite) TestCompareSubquery(c *C) {
))
tk.MustQuery("select * from t t1 where b = all (select a from t t2)").Check(testkit.Rows())
}

func (s *testExpressionRewriterSuite) TestCheckFullGroupBy(c *C) {
defer testleak.AfterTest(c)()
store, dom, err := newStoreWithBootstrap()
c.Assert(err, IsNil)
tk := testkit.NewTestKit(c, store)
defer func() {
dom.Close()
store.Close()
}()
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int)")
tk.MustQuery("select t1.a, (select max(t2.b) from t t2) from t t1").Check(testkit.Rows())
}
2 changes: 2 additions & 0 deletions planner/core/logical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,8 @@ func (c *colResolverForOnlyFullGroupBy) Enter(node ast.Node) (ast.Node, bool) {
c.firstNonAggCol, c.firstNonAggColIdx = t.Name, c.exprIdx
}
return node, true
case *ast.SubqueryExpr:
return node, true
}
return node, false
}
Expand Down

0 comments on commit 24c9b99

Please sign in to comment.