func (v *havingVisitor) VisitCall(c *expression.Call) (expression.Expression, error) { isAggregate := expression.IsAggregateFunc(c.F) if v.inAggregate && isAggregate { // aggregate function can't contain aggregate function return nil, errors.Errorf("Invalid use of group function") } if isAggregate { // set true to let outer know we are in aggregate function. v.inAggregate = true } var err error for i, e := range c.Args { c.Args[i], err = e.Accept(v) if err != nil { return nil, errors.Trace(err) } } if isAggregate { v.inAggregate = false } return c, nil }
func (v *groupByVisitor) VisitCall(c *expression.Call) (expression.Expression, error) { ok := expression.IsAggregateFunc(c.F) if ok { return nil, errors.Errorf("group by cannot contain aggregate function %s", c) } var err error for i, e := range c.Args { c.Args[i], err = e.Accept(v) if err != nil { return nil, errors.Trace(err) } } return c, nil }