Merge pull request #5776 from influxdata/js-5773-unsupported-call-panic

Replace a panic with returning an error when an unsupported call is used
pull/5737/merge
Jonathan A. Sternberg 2016-02-22 08:17:59 -05:00
commit 87e04b1a46
2 changed files with 13 additions and 1 deletions

View File

@ -321,7 +321,7 @@ func buildExprIterator(expr Expr, ic IteratorCreator, opt IteratorOptions) (Iter
opt.StartTime, opt.EndTime = MinTime, MaxTime opt.StartTime, opt.EndTime = MinTime, MaxTime
return newDerivativeIterator(input, opt, interval, isNonNegative), nil return newDerivativeIterator(input, opt, interval, isNonNegative), nil
default: default:
panic(fmt.Sprintf("unsupported call: %s", expr.Name)) return nil, fmt.Errorf("unsupported call: %s", expr.Name)
} }
if err != nil { if err != nil {

View File

@ -1584,3 +1584,15 @@ func TestSelect_Derivative_Integer(t *testing.T) {
t.Fatalf("unexpected points: %s", spew.Sdump(a)) t.Fatalf("unexpected points: %s", spew.Sdump(a))
} }
} }
func TestSelect_UnsupportedCall(t *testing.T) {
var ic IteratorCreator
ic.CreateIteratorFn = func(opt influxql.IteratorOptions) (influxql.Iterator, error) {
return &FloatIterator{}, nil
}
_, err := influxql.Select(MustParseSelectStatement(`SELECT foobar(value) FROM cpu`), &ic, nil)
if err == nil || err.Error() != "unsupported call: foobar" {
t.Errorf("unexpected error: %s", err)
}
}