mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-30 15:22:07 +00:00
lib/metricsql: export IsRollupFunc and IsTransformFunc, since they can be used by package users
This commit is contained in:
parent
8cfd4decea
commit
89b551201c
3 changed files with 9 additions and 6 deletions
|
@ -261,7 +261,7 @@ func (p *parser) parseWithArgExpr() (*withArgExpr, error) {
|
||||||
return nil, fmt.Errorf(`withArgExpr: unexpected token %q; want "ident"`, p.lex.Token)
|
return nil, fmt.Errorf(`withArgExpr: unexpected token %q; want "ident"`, p.lex.Token)
|
||||||
}
|
}
|
||||||
wa.Name = 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)
|
return nil, fmt.Errorf(`withArgExpr: cannot use reserved name %q`, wa.Name)
|
||||||
}
|
}
|
||||||
if err := p.lex.Next(); err != nil {
|
if err := p.lex.Next(); err != nil {
|
||||||
|
|
|
@ -53,7 +53,8 @@ var rollupFuncs = map[string]bool{
|
||||||
"rollup_candlestick": true,
|
"rollup_candlestick": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func isRollupFunc(funcName string) bool {
|
// IsRollupFunc returns whether funcName is known rollup function.
|
||||||
funcName = strings.ToLower(funcName)
|
func IsRollupFunc(funcName string) bool {
|
||||||
return rollupFuncs[funcName]
|
s := strings.ToLower(funcName)
|
||||||
|
return rollupFuncs[s]
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,9 @@ var transformFuncs = map[string]bool{
|
||||||
"histogram_share": true,
|
"histogram_share": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func isTransformFunc(s string) bool {
|
// IsTransformFunc returns whether funcName is known transform function.
|
||||||
s = strings.ToLower(s)
|
func IsTransformFunc(funcName string) bool {
|
||||||
|
s := strings.ToLower(funcName)
|
||||||
return transformFuncs[s]
|
return transformFuncs[s]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue