This commit is contained in:
Aliaksandr Valialkin 2024-04-27 01:53:32 +02:00
parent 9f8dd1ef31
commit 51b869d458
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 10 additions and 7 deletions

View file

@ -231,6 +231,10 @@ func ParseQuery(s string) (*Query, error) {
}
q.pipes = pipes
if !lex.isEnd() {
return nil, fmt.Errorf("unexpected unparsed tail; context: %s", lex.context())
}
return q, nil
}

View file

@ -59,7 +59,7 @@ func (dpp defaultPipeProcessor) flush() {
func parsePipes(lex *lexer) ([]pipe, error) {
var pipes []pipe
for !lex.isEnd() {
for !lex.isKeyword(")", "") {
if !lex.isKeyword("|") {
return nil, fmt.Errorf("expecting '|'")
}
@ -151,14 +151,14 @@ func parseFieldsPipe(lex *lexer) (*fieldsPipe, error) {
field := parseFieldName(lex)
fields = append(fields, field)
switch {
case lex.isKeyword("|", ""):
case lex.isKeyword("|", ")", ""):
fp := &fieldsPipe{
fields: fields,
}
return fp, nil
case lex.isKeyword(","):
default:
return nil, fmt.Errorf("unexpected token: %q; expecting ',' or '|'", lex.token)
return nil, fmt.Errorf("unexpected token: %q; expecting ',', '|' or ')'", lex.token)
}
}
}
@ -244,8 +244,7 @@ type statsPipeProcessor struct {
type statsPipeProcessorShard struct {
statsPipeProcessorShardNopad
// The padding prevents false sharing on widespread platforms with
// 128 mod (cache line size) = 0 .
// The padding prevents false sharing on widespread platforms with 128 mod (cache line size) = 0 .
_ [128 - unsafe.Sizeof(statsPipeProcessorShardNopad{})%128]byte
}
@ -444,12 +443,12 @@ func parseStatsPipe(lex *lexer) (*statsPipe, error) {
return nil, err
}
funcs = append(funcs, sf)
if lex.isKeyword("|", "") {
if lex.isKeyword("|", ")", "") {
sp.funcs = funcs
return &sp, nil
}
if !lex.isKeyword(",") {
return nil, fmt.Errorf("unexpected token %q; want ',' or '|'", lex.token)
return nil, fmt.Errorf("unexpected token %q; want ',', '|' or ')'", lex.token)
}
lex.nextToken()
}