diff --git a/lib/metricsql/parser.go b/lib/metricsql/parser.go index 6feb3fe1c..10febd145 100644 --- a/lib/metricsql/parser.go +++ b/lib/metricsql/parser.go @@ -261,7 +261,7 @@ func (p *parser) parseWithArgExpr() (*withArgExpr, error) { return nil, fmt.Errorf(`withArgExpr: unexpected token %q; want "ident"`, p.lex.Token) } wa.Name = p.lex.Token - if isAggrFunc(wa.Name) || isRollupFunc(wa.Name) || isTransformFunc(wa.Name) || isWith(wa.Name) { + if isAggrFunc(wa.Name) || IsRollupFunc(wa.Name) || IsTransformFunc(wa.Name) || isWith(wa.Name) { return nil, fmt.Errorf(`withArgExpr: cannot use reserved name %q`, wa.Name) } if err := p.lex.Next(); err != nil { diff --git a/lib/metricsql/rollup.go b/lib/metricsql/rollup.go index aa3c63c1e..7406e1471 100644 --- a/lib/metricsql/rollup.go +++ b/lib/metricsql/rollup.go @@ -53,7 +53,8 @@ var rollupFuncs = map[string]bool{ "rollup_candlestick": true, } -func isRollupFunc(funcName string) bool { - funcName = strings.ToLower(funcName) - return rollupFuncs[funcName] +// IsRollupFunc returns whether funcName is known rollup function. +func IsRollupFunc(funcName string) bool { + s := strings.ToLower(funcName) + return rollupFuncs[s] } diff --git a/lib/metricsql/transform.go b/lib/metricsql/transform.go index 74f840f7e..16094dfdd 100644 --- a/lib/metricsql/transform.go +++ b/lib/metricsql/transform.go @@ -75,7 +75,9 @@ var transformFuncs = map[string]bool{ "histogram_share": true, } -func isTransformFunc(s string) bool { - s = strings.ToLower(s) +// IsTransformFunc returns whether funcName is known transform function. +func IsTransformFunc(funcName string) bool { + s := strings.ToLower(funcName) return transformFuncs[s] + }