code: func (b *PlanBuilder) detectSelectAgg(sel *ast.SelectStmt) bool {
  	if sel.GroupBy != nil {
  		return true
  	}
  	for _, f := range sel.Fields.Fields {
  		if ast.HasAggFlag(f.Expr) {
  			return true
  		}
  	}
  	if sel.Having != nil {
  		if ast.HasAggFlag(sel.Having.Expr) {
  			return true
  		}
  	}
  	if sel.OrderBy != nil {
  		for _, item := range sel.OrderBy.Items {
  			if ast.HasAggFlag(item.Expr) {
  				return true
  			}
  		}
  	}
  	return false
  }
docs: // detectSelectAgg detects an aggregate function or GROUP BY clause.