From cc51a28b60d45352283d12592c80f0d45eac9781 Mon Sep 17 00:00:00 2001 From: Vivek Patel Date: Thu, 26 Jan 2023 15:49:51 +0530 Subject: [PATCH] Fix broken tests - TestStepAggregate - TestQLWrapParsing By fixing ast node parsing for more than 2 argument operators --- server/pkg/ql/ast_nodes.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/server/pkg/ql/ast_nodes.go b/server/pkg/ql/ast_nodes.go index 4c191332a..246649ad5 100644 --- a/server/pkg/ql/ast_nodes.go +++ b/server/pkg/ql/ast_nodes.go @@ -319,16 +319,13 @@ func (nn parserNodes) ToAST() (out *ASTNode) { // Have the op consume what it needs. arg := auxArgs[bestOpIx] if !isUnary(arg.Ref) { - for i, auxArg := range auxArgs { - if isOperator(auxArg.Ref) { - break + skip := 2 + arg.Args = append(arg.Args, auxArgs[bestOpIx-1], auxArgs[bestOpIx+1]) + if bestOpIx > -1 && len(auxArgs) > bestOpIx+2 { + if !isOperator(auxArgs[bestOpIx+2].Ref) { + skip = 3 + arg.Args = append(arg.Args, auxArgs[bestOpIx+2]) } - - if i == bestOpIx { - continue - } - - arg.Args = append(arg.Args, auxArg) } // this is not needed anymore so we can remove it @@ -338,10 +335,6 @@ func (nn parserNodes) ToAST() (out *ASTNode) { aux := auxArgs[0 : bestOpIx-1] aux = append(aux, arg) // +X for right side, +1 because the left index is inclusive - skip := 2 - if len(arg.Args) > 2 { - skip = len(arg.Args) - } aux = append(aux, auxArgs[bestOpIx+skip:]...) auxArgs = aux } else {