From 344db8ff1e625aca46203ef7d87837c25c6b754e Mon Sep 17 00:00:00 2001 From: Todd Persen Date: Wed, 20 May 2015 14:55:19 -0700 Subject: [PATCH] Fix up parser and handle new error message. --- influxql/parser.go | 8 +++++--- influxql/parser_test.go | 10 +--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/influxql/parser.go b/influxql/parser.go index 897205b52e..62db65dc6a 100644 --- a/influxql/parser.go +++ b/influxql/parser.go @@ -1023,7 +1023,9 @@ func (p *Parser) parseDropSeriesStatement() (*DropSeriesStatement, error) { stmt := &DropSeriesStatement{} var err error - if tok, _, _ := p.scanIgnoreWhitespace(); tok == FROM { + tok, pos, lit := p.scanIgnoreWhitespace() + + if tok == FROM { // Parse source. if stmt.Source, err = p.parseSource(); err != nil { return nil, err @@ -1037,9 +1039,9 @@ func (p *Parser) parseDropSeriesStatement() (*DropSeriesStatement, error) { return nil, err } - // If they didn't provide a FROM or a WHERE, they need to provide the SeriesID + // If they didn't provide a FROM or a WHERE, this query is invalid if stmt.Condition == nil && stmt.Source == nil { - return nil, fmt.Errorf("DROP SERIES requires a FROM or WHERE clause") + return nil, newParseError(tokstr(tok, lit), []string{"FROM", "WHERE"}, pos) } return stmt, nil diff --git a/influxql/parser_test.go b/influxql/parser_test.go index 3b40a2015d..6ae5b79ee7 100644 --- a/influxql/parser_test.go +++ b/influxql/parser_test.go @@ -717,10 +717,6 @@ func TestParser_ParseStatement(t *testing.T) { }, // DROP SERIES statement - { - s: `DROP SERIES 1`, - stmt: &influxql.DropSeriesStatement{SeriesID: 1}, - }, { s: `DROP SERIES FROM src`, stmt: &influxql.DropSeriesStatement{Source: &influxql.Measurement{Name: "src"}}, @@ -1158,7 +1154,7 @@ func TestParser_ParseStatement(t *testing.T) { {s: `DELETE FROM`, err: `found EOF, expected identifier at line 1, char 13`}, {s: `DELETE FROM myseries WHERE`, err: `found EOF, expected identifier, string, number, bool at line 1, char 28`}, {s: `DROP MEASUREMENT`, err: `found EOF, expected identifier at line 1, char 18`}, - {s: `DROP SERIES`, err: `found EOF, expected number at line 1, char 13`}, + {s: `DROP SERIES`, err: `found EOF, expected FROM, WHERE at line 1, char 13`}, {s: `DROP SERIES FROM`, err: `found EOF, expected identifier at line 1, char 18`}, {s: `DROP SERIES FROM src WHERE`, err: `found EOF, expected identifier, string, number, bool at line 1, char 28`}, {s: `SHOW CONTINUOUS`, err: `found EOF, expected QUERIES at line 1, char 17`}, @@ -1530,10 +1526,6 @@ func TestDropSeriesStatement_String(t *testing.T) { s string stmt influxql.Statement }{ - { - s: `DROP SERIES 1`, - stmt: &influxql.DropSeriesStatement{SeriesID: 1}, - }, { s: `DROP SERIES FROM src`, stmt: &influxql.DropSeriesStatement{Source: &influxql.Measurement{Name: "src"}},