mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
3fa5ca8a8f
commit
a013cb0ca3
3 changed files with 9 additions and 14 deletions
|
@ -1081,6 +1081,10 @@ func TestParseQuerySuccess(t *testing.T) {
|
|||
f(`foo | # some comment | foo bar
|
||||
fields x # another comment
|
||||
|filter "foo#this#isn't a comment"#this is comment`, `foo | fields x | filter "foo#this#isn't a comment"`)
|
||||
|
||||
// skip 'stats' and 'filter' prefixes
|
||||
f(`* | by (host) count() rows | rows:>10`, `* | stats by (host) count(*) as rows | filter rows:>10`)
|
||||
f(`* | (host) count() rows, count() if (error) errors | rows:>10`, `* | stats by (host) count(*) as rows, count(*) if (error) as errors | filter rows:>10`)
|
||||
}
|
||||
|
||||
func TestParseQueryFailure(t *testing.T) {
|
||||
|
|
|
@ -149,7 +149,7 @@ func parsePipe(lex *lexer) (pipe, error) {
|
|||
}
|
||||
return pl, nil
|
||||
case lex.isKeyword("math"):
|
||||
pm, err := parsePipeMath(lex, true)
|
||||
pm, err := parsePipeMath(lex)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot parse 'math' pipe: %w", err)
|
||||
}
|
||||
|
@ -223,13 +223,6 @@ func parsePipe(lex *lexer) (pipe, error) {
|
|||
default:
|
||||
lexState := lex.backupState()
|
||||
|
||||
// Try parsing math pipe without 'math' keyword
|
||||
pm, err := parsePipeMath(lex, false)
|
||||
if err == nil {
|
||||
return pm, nil
|
||||
}
|
||||
lex.restoreState(lexState)
|
||||
|
||||
// Try parsing stats pipe without 'stats' keyword
|
||||
ps, err := parsePipeStats(lex, false)
|
||||
if err == nil {
|
||||
|
|
|
@ -350,13 +350,11 @@ func (pmp *pipeMathProcessor) flush() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func parsePipeMath(lex *lexer, needMathKeyword bool) (*pipeMath, error) {
|
||||
if needMathKeyword {
|
||||
func parsePipeMath(lex *lexer) (*pipeMath, error) {
|
||||
if !lex.isKeyword("math") {
|
||||
return nil, fmt.Errorf("unexpected token: %q; want %q", lex.token, "math")
|
||||
}
|
||||
lex.nextToken()
|
||||
}
|
||||
|
||||
var mes []*mathEntry
|
||||
for {
|
||||
|
|
Loading…
Reference in a new issue