Skip to content

Commit

Permalink
Revert some changes - PPL math operation precedence was broken.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Jan 16, 2023
1 parent 292370c commit b11b239
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions ppl/src/main/antlr/OpenSearchPPLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ comparisonExpression

valueExpression
: left=valueExpression
binaryOperator//=(STAR | DIVIDE | MODULE)
binaryOperator=(STAR | DIVIDE | MODULE)
right=valueExpression #binaryArithmetic
| left=valueExpression
binaryOperator//=(PLUS | MINUS)
binaryOperator=(PLUS | MINUS)
right=valueExpression #binaryArithmetic
| primaryExpression #valueExpressionDefault
| positionFunction #positionFunctionCall
Expand Down Expand Up @@ -597,14 +597,6 @@ comparisonOperator
| REGEXP
;

binaryOperator
: PLUS
| MINUS
| STAR
| DIVIDE
| MODULE
;

singleFieldRelevanceFunctionName
: MATCH
| MATCH_PHRASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public UnresolvedExpression visitInExpr(InExprContext ctx) {
@Override
public UnresolvedExpression visitBinaryArithmetic(BinaryArithmeticContext ctx) {
return new Function(
ctx.binaryOperator().getText(),
ctx.binaryOperator.getText(),
Arrays.asList(visit(ctx.left), visit(ctx.right))
);
}
Expand Down

0 comments on commit b11b239

Please sign in to comment.