diff --git a/influxql/ast.go b/influxql/ast.go index 9bb5731aaf..ad147a9346 100644 --- a/influxql/ast.go +++ b/influxql/ast.go @@ -77,8 +77,8 @@ func (_ *DurationLiteral) node() {} func (_ *BinaryExpr) node() {} func (_ *ParenExpr) node() {} func (_ *Wildcard) node() {} -func (_ SortFields) node() {} -func (_ *SortField) node() {} +func (_ SortFields) node() {} +func (_ *SortField) node() {} // Query represents a collection of ordered statements. type Query struct { @@ -273,7 +273,7 @@ func (s *SelectStatement) Substatement(ref *VarRef) (*SelectStatement, error) { Fields: Fields{{Expr: ref}}, Dimensions: s.Dimensions, Limit: s.Limit, - SortFields: s.SortFields, + SortFields: s.SortFields, } // If there is only one series source then return it with the whole condition. @@ -382,7 +382,7 @@ func (s *DeleteStatement) String() string { } // ListSeriesStatement represents a command for listing series in the database. -type ListSeriesStatement struct{ +type ListSeriesStatement struct { // An expression evaluated on a series name or tag. Condition Expr @@ -465,7 +465,7 @@ type ListMeasurementsStatement struct { // String returns a string representation of the statement. func (s *ListMeasurementsStatement) String() string { - var buf bytes.Buffer + var buf bytes.Buffer _, _ = buf.WriteString("LIST MEASUREMENTS") if s.Condition != nil { @@ -501,7 +501,7 @@ type ListTagKeysStatement struct { // String returns a string representation of the statement. func (s *ListTagKeysStatement) String() string { - var buf bytes.Buffer + var buf bytes.Buffer _, _ = buf.WriteString("LIST TAG KEYS") if s.Source != nil { @@ -541,7 +541,7 @@ type ListTagValuesStatement struct { // String returns a string representation of the statement. func (s *ListTagValuesStatement) String() string { - var buf bytes.Buffer + var buf bytes.Buffer _, _ = buf.WriteString("LIST TAG VALUES") if s.Source != nil { @@ -581,7 +581,7 @@ type ListFieldKeysStatement struct { // String returns a string representation of the statement. func (s *ListFieldKeysStatement) String() string { - var buf bytes.Buffer + var buf bytes.Buffer _, _ = buf.WriteString("LIST FIELD KEYS") if s.Source != nil { @@ -621,7 +621,7 @@ type ListFieldValuesStatement struct { // String returns a string representation of the statement. func (s *ListFieldValuesStatement) String() string { - var buf bytes.Buffer + var buf bytes.Buffer _, _ = buf.WriteString("LIST FIELD VALUES") if s.Source != nil { @@ -642,6 +642,7 @@ func (s *ListFieldValuesStatement) String() string { } return buf.String() } + // Fields represents a list of fields. type Fields []*Field diff --git a/influxql/parser.go b/influxql/parser.go index 1fc3f826c7..a7a4248204 100644 --- a/influxql/parser.go +++ b/influxql/parser.go @@ -759,7 +759,7 @@ func (p *Parser) parseSortFields() (SortFields, error) { // Parse additional fields. for { tok, _, _ := p.scanIgnoreWhitespace() - + if tok != COMMA { p.unscan() break diff --git a/influxql/parser_test.go b/influxql/parser_test.go index 34f0866ce8..a649db9609 100644 --- a/influxql/parser_test.go +++ b/influxql/parser_test.go @@ -74,7 +74,7 @@ func TestParser_ParseStatement(t *testing.T) { Dimensions: influxql.Dimensions{ &influxql.Dimension{Expr: &influxql.DurationLiteral{Val: 10 * time.Hour}}, }, - Limit: 20, + Limit: 20, SortFields: influxql.SortFields{ &influxql.SortField{Ascending: true}, }, @@ -127,9 +127,9 @@ func TestParser_ParseStatement(t *testing.T) { Fields: influxql.Fields{&influxql.Field{Expr: &influxql.VarRef{Val: "field1"}}}, Source: &influxql.Series{Name: "myseries"}, SortFields: influxql.SortFields{ - &influxql.SortField{Ascending: true,}, - &influxql.SortField{Name: "field1",}, - &influxql.SortField{Name: "field2",}, + &influxql.SortField{Ascending: true}, + &influxql.SortField{Name: "field1"}, + &influxql.SortField{Name: "field2"}, }, Limit: 10, }, @@ -156,17 +156,17 @@ func TestParser_ParseStatement(t *testing.T) { // LIST SERIES WHERE with ORDER BY and LIMIT { - s: `LIST SERIES WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, + s: `LIST SERIES WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, stmt: &influxql.ListSeriesStatement{ Condition: &influxql.BinaryExpr{ - Op: influxql.EQ, + Op: influxql.EQ, LHS: &influxql.VarRef{Val: "region"}, RHS: &influxql.StringLiteral{Val: "uswest"}, }, SortFields: influxql.SortFields{ - &influxql.SortField{Ascending: true,}, - &influxql.SortField{Name: "field1",}, - &influxql.SortField{Name: "field2",}, + &influxql.SortField{Ascending: true}, + &influxql.SortField{Name: "field1"}, + &influxql.SortField{Name: "field2"}, }, Limit: 10, }, @@ -174,17 +174,17 @@ func TestParser_ParseStatement(t *testing.T) { // LIST MEASUREMENTS WHERE with ORDER BY and LIMIT { - s: `LIST MEASUREMENTS WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, + s: `LIST MEASUREMENTS WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, stmt: &influxql.ListMeasurementsStatement{ Condition: &influxql.BinaryExpr{ - Op: influxql.EQ, + Op: influxql.EQ, LHS: &influxql.VarRef{Val: "region"}, RHS: &influxql.StringLiteral{Val: "uswest"}, }, SortFields: influxql.SortFields{ - &influxql.SortField{Ascending: true,}, - &influxql.SortField{Name: "field1",}, - &influxql.SortField{Name: "field2",}, + &influxql.SortField{Ascending: true}, + &influxql.SortField{Name: "field1"}, + &influxql.SortField{Name: "field2"}, }, Limit: 10, }, @@ -192,18 +192,18 @@ func TestParser_ParseStatement(t *testing.T) { // LIST TAG KEYS { - s: `LIST TAG KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, + s: `LIST TAG KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, stmt: &influxql.ListTagKeysStatement{ Source: &influxql.Series{Name: "src"}, Condition: &influxql.BinaryExpr{ - Op: influxql.EQ, + Op: influxql.EQ, LHS: &influxql.VarRef{Val: "region"}, RHS: &influxql.StringLiteral{Val: "uswest"}, }, SortFields: influxql.SortFields{ - &influxql.SortField{Ascending: true,}, - &influxql.SortField{Name: "field1",}, - &influxql.SortField{Name: "field2",}, + &influxql.SortField{Ascending: true}, + &influxql.SortField{Name: "field1"}, + &influxql.SortField{Name: "field2"}, }, Limit: 10, }, @@ -211,18 +211,18 @@ func TestParser_ParseStatement(t *testing.T) { // LIST TAG VALUES { - s: `LIST TAG VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, + s: `LIST TAG VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, stmt: &influxql.ListTagValuesStatement{ Source: &influxql.Series{Name: "src"}, Condition: &influxql.BinaryExpr{ - Op: influxql.EQ, + Op: influxql.EQ, LHS: &influxql.VarRef{Val: "region"}, RHS: &influxql.StringLiteral{Val: "uswest"}, }, SortFields: influxql.SortFields{ - &influxql.SortField{Ascending: true,}, - &influxql.SortField{Name: "field1",}, - &influxql.SortField{Name: "field2",}, + &influxql.SortField{Ascending: true}, + &influxql.SortField{Name: "field1"}, + &influxql.SortField{Name: "field2"}, }, Limit: 10, }, @@ -230,18 +230,18 @@ func TestParser_ParseStatement(t *testing.T) { // LIST FIELD KEYS { - s: `LIST FIELD KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, + s: `LIST FIELD KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, stmt: &influxql.ListFieldKeysStatement{ Source: &influxql.Series{Name: "src"}, Condition: &influxql.BinaryExpr{ - Op: influxql.EQ, + Op: influxql.EQ, LHS: &influxql.VarRef{Val: "region"}, RHS: &influxql.StringLiteral{Val: "uswest"}, }, SortFields: influxql.SortFields{ - &influxql.SortField{Ascending: true,}, - &influxql.SortField{Name: "field1",}, - &influxql.SortField{Name: "field2",}, + &influxql.SortField{Ascending: true}, + &influxql.SortField{Name: "field1"}, + &influxql.SortField{Name: "field2"}, }, Limit: 10, }, @@ -249,18 +249,18 @@ func TestParser_ParseStatement(t *testing.T) { // LIST FIELD VALUES { - s: `LIST FIELD VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, + s: `LIST FIELD VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`, stmt: &influxql.ListFieldValuesStatement{ Source: &influxql.Series{Name: "src"}, Condition: &influxql.BinaryExpr{ - Op: influxql.EQ, + Op: influxql.EQ, LHS: &influxql.VarRef{Val: "region"}, RHS: &influxql.StringLiteral{Val: "uswest"}, }, SortFields: influxql.SortFields{ - &influxql.SortField{Ascending: true,}, - &influxql.SortField{Name: "field1",}, - &influxql.SortField{Name: "field2",}, + &influxql.SortField{Ascending: true}, + &influxql.SortField{Name: "field1"}, + &influxql.SortField{Name: "field2"}, }, Limit: 10, }, diff --git a/influxql/scanner_test.go b/influxql/scanner_test.go index 5b6883ea2a..b16837edf9 100644 --- a/influxql/scanner_test.go +++ b/influxql/scanner_test.go @@ -190,4 +190,4 @@ func TestScanner_Scan_Multi(t *testing.T) { t.Fatalf("%d. token mismatch:\n\nexp=%#v\n\ngot=%#v", i, exp[i], act[i]) } } -} \ No newline at end of file +}