Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Arithmetic expressions in DataPrepper expression #2685

Closed
kkondaka opened this issue May 12, 2023 · 1 comment · Fixed by #2726
Closed

Add support for Arithmetic expressions in DataPrepper expression #2685

kkondaka opened this issue May 12, 2023 · 1 comment · Fixed by #2726
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@kkondaka
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Add support for Arithmetic expressions in DataPrepper expression.
Some discussion is in previous RFC #1005.

Describe the solution you'd like

Suggested grammar for supporting full Arithmetic expressions in DataPrepper expressions

arithmeticExpression
    : arithmeticExpression (PLUS | MINUS) arithmeticTerm
    | arithmeticTerm
    ;

arithmeticTerm
    : arithmeticTerm (MULTIPLY | DIVIDE) arithmeticFactor
    | arithmeticFactor
    ;

arithmeticFactor
    : Function
    | JsonPointer
    | Integer
    | Float
    | LPAREN arithmeticExpression RPAREN
    | SUBTRACT arithmeticFactor
    ;

This allows for +,=,*,/ arithmetic operators and also functions as operands

Describe alternatives you've considered (Optional)
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@kkondaka kkondaka added this to the v2.4 milestone May 12, 2023
@dlvenable dlvenable added enhancement New feature or request and removed untriaged labels May 15, 2023
@kkondaka kkondaka self-assigned this May 15, 2023
@kkondaka
Copy link
Collaborator Author

This issue will be addressed in two phases. First phase will only support Number literals and functions returning integers in the expression with the following grammar

 expression
     : conditionalExpression EOF
     | arithmeticExpression EOF
     | OTHER {System.err.println("unknown char: " + $OTHER.text);}
     ;

arithmeticExpression
    : function
    | jsonPointer
    | Integer
    | Float
    ;

The rest of the functionality (like supporting arithmetic operators +, -, *, / will be added in the second phase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants