Fix up parser and handle new error message.

pull/2624/head
Todd Persen 2015-05-20 14:55:19 -07:00
parent e7c40e5cae
commit 344db8ff1e
2 changed files with 6 additions and 12 deletions

View File

@ -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

View File

@ -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"}},