Skip to content

Commit

Permalink
plan: support aggregation function contains aggregation function (pin…
Browse files Browse the repository at this point in the history
  • Loading branch information
XuHuaiyu authored and hanfei1991 committed Sep 18, 2017
1 parent 339c93e commit d38135d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 0 additions & 5 deletions plan/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ type validator struct {
func (v *validator) Enter(in ast.Node) (out ast.Node, skipChildren bool) {
switch node := in.(type) {
case *ast.AggregateFuncExpr:
if v.inAggregate {
// Aggregate function can not contain aggregate function.
v.err = ErrInvalidGroupFuncUse
return in, true
}
v.inAggregate = true
case *ast.CreateTableStmt:
v.checkCreateTableGrammar(node)
Expand Down
4 changes: 4 additions & 0 deletions plan/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func (s *testValidatorSuite) TestValidator(c *C) {
{"CREATE TABLE `t` (`a` float DEFAULT now());", false, types.ErrInvalidDefault},
{"CREATE TABLE `t` (`a` varchar(10) DEFAULT now());", false, types.ErrInvalidDefault},
{"CREATE TABLE `t` (`a` double DEFAULT 1.0 DEFAULT now() DEFAULT 2.0 );", false, nil},

// issue 4472
{`select sum(distinct(if('a', (select adddate(elt(999, count(*)), interval 1 day)), .1))) as foo;`, true, nil},
{`select sum(1 in (select count(1)))`, true, nil},
}

store, err := tidb.NewStore(tidb.EngineGoLevelDBMemory)
Expand Down

0 comments on commit d38135d

Please sign in to comment.