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
|
f(`foo | # some comment | foo bar
|
||||||
fields x # another comment
|
fields x # another comment
|
||||||
|filter "foo#this#isn't a comment"#this is comment`, `foo | fields x | filter "foo#this#isn't a 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) {
|
func TestParseQueryFailure(t *testing.T) {
|
||||||
|
|
|
@ -149,7 +149,7 @@ func parsePipe(lex *lexer) (pipe, error) {
|
||||||
}
|
}
|
||||||
return pl, nil
|
return pl, nil
|
||||||
case lex.isKeyword("math"):
|
case lex.isKeyword("math"):
|
||||||
pm, err := parsePipeMath(lex, true)
|
pm, err := parsePipeMath(lex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot parse 'math' pipe: %w", err)
|
return nil, fmt.Errorf("cannot parse 'math' pipe: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -223,13 +223,6 @@ func parsePipe(lex *lexer) (pipe, error) {
|
||||||
default:
|
default:
|
||||||
lexState := lex.backupState()
|
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
|
// Try parsing stats pipe without 'stats' keyword
|
||||||
ps, err := parsePipeStats(lex, false)
|
ps, err := parsePipeStats(lex, false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -350,13 +350,11 @@ func (pmp *pipeMathProcessor) flush() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePipeMath(lex *lexer, needMathKeyword bool) (*pipeMath, error) {
|
func parsePipeMath(lex *lexer) (*pipeMath, error) {
|
||||||
if needMathKeyword {
|
|
||||||
if !lex.isKeyword("math") {
|
if !lex.isKeyword("math") {
|
||||||
return nil, fmt.Errorf("unexpected token: %q; want %q", lex.token, "math")
|
return nil, fmt.Errorf("unexpected token: %q; want %q", lex.token, "math")
|
||||||
}
|
}
|
||||||
lex.nextToken()
|
lex.nextToken()
|
||||||
}
|
|
||||||
|
|
||||||
var mes []*mathEntry
|
var mes []*mathEntry
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in a new issue