Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error message when improper types are used in SELECT #5953

Merged
merged 1 commit into from
Mar 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
- [#5865](https://github.com/influxdata/influxdb/issues/5865): Conversion to tsm fails with exceeds max index value
- [#5924](https://github.com/influxdata/influxdb/issues/5924): Missing data after using influx\_tsm
- [#5937](https://github.com/influxdata/influxdb/pull/5937): Rewrite SHOW SERIES to use query engine
- [#5949](https://github.com/influxdata/influxdb/issues/5949): Return error message when improper types are used in SELECT

## v0.10.2 [2016-03-03]
### Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion influxql/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ func buildExprIterator(expr Expr, ic IteratorCreator, opt IteratorOptions) (Iter
case *ParenExpr:
return buildExprIterator(expr.Expr, ic, opt)
default:
panic(fmt.Sprintf("invalid expression type: %T", expr)) // FIXME
return nil, fmt.Errorf("invalid expression type: %T", expr)
}
}

Expand Down
29 changes: 29 additions & 0 deletions influxql/select_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1686,3 +1686,32 @@ func TestSelect_UnsupportedCall(t *testing.T) {
t.Errorf("unexpected error: %s", err)
}
}

func TestSelect_InvalidQueries(t *testing.T) {
var ic IteratorCreator
ic.CreateIteratorFn = func(opt influxql.IteratorOptions) (influxql.Iterator, error) {
return &FloatIterator{}, nil
}

tests := []struct {
q string
err string
}{
{
q: `SELECT foobar(value) FROM cpu`,
err: `unsupported call: foobar`,
},
{
q: `SELECT 'value' FROM cpu`,
err: `invalid expression type: *influxql.StringLiteral`,
},
}

for i, tt := range tests {
itrs, err := influxql.Select(MustParseSelectStatement(tt.q), &ic, nil)
if err == nil || err.Error() != tt.err {
t.Errorf("%d. expected error '%s', got '%s'", i, tt.err, err)
}
influxql.Iterators(itrs).Close()
}
}