diff --git a/server.go b/server.go index 010808781a..c9e727c08f 100644 --- a/server.go +++ b/server.go @@ -1850,23 +1850,33 @@ func (s *Server) planSelectStatement(stmt *influxql.SelectStatement, database st // If this is a wildcard statement, expand this to use the fields // This is temporary until we move other parts of the system further - if len(stmt.Fields) == 1 { - if _, ok := stmt.Fields[0].Expr.(*influxql.Wildcard); ok { - if measurement, ok := stmt.Source.(*influxql.Measurement); ok { - segments, err := influxql.SplitIdent(measurement.Name) - if err != nil { - return nil, fmt.Errorf("unable to parse measurement %s", measurement.Name) - } - db, m := segments[0], segments[2] - if s.databases[db].measurements[m] == nil { - return nil, fmt.Errorf("measurement %s does not exist.", measurement.Name) - } - var fields influxql.Fields - for _, f := range s.databases[db].measurements[m].Fields { - fields = append(fields, &influxql.Field{Expr: &influxql.VarRef{Val: f.Name}}) - } - stmt.Fields = fields + isWildcard := false + for _, f := range stmt.Fields { + if _, ok := f.Expr.(*influxql.Wildcard); ok { + isWildcard = true + break + } + } + + if len(stmt.Fields) != 1 && isWildcard { + return nil, fmt.Errorf("unsupported query: %s. currently only single wildcard is supported.", stmt.String()) + } + + if isWildcard { + if measurement, ok := stmt.Source.(*influxql.Measurement); ok { + segments, err := influxql.SplitIdent(measurement.Name) + if err != nil { + return nil, fmt.Errorf("unable to parse measurement %s", measurement.Name) } + db, m := segments[0], segments[2] + if s.databases[db].measurements[m] == nil { + return nil, fmt.Errorf("measurement %s does not exist.", measurement.Name) + } + var fields influxql.Fields + for _, f := range s.databases[db].measurements[m].Fields { + fields = append(fields, &influxql.Field{Expr: &influxql.VarRef{Val: f.Name}}) + } + stmt.Fields = fields } }