Skip to content

[BUG] Issues in PPL grammar #3391

@vikhy-aws

Description

@vikhy-aws

What is the bug?
PPL grammar currently does not account for precedence for logical operators (AND, OR, XOR, NOT). Also, usage of parentheses is not supported in logical expressions. Also, the grammar is not case-agnostic, only supports uppercase.

How can one reproduce the bug?
All these can be simulated using antlr parser using sample PPL queries and the grammar.

What is the expected behavior?
Precedence must be accounted for logical operators according to the rules of the language. Usage of parentheses must be allowed in logical expressions. Also, support case-agnostic queries.

What is your host/environment?

  • OS: Mac
  • Version [e.g. 22]
  • Plugins

Do you have any screenshots?

  1. The following screenshot shows that operator precedence is not as expected. We would expect the AND operator to be evaluated first before OR.
    Query Used: SOURCE=TEST | WHERE A1 = 'V1' AND A2 = 'V2' AND A3 = 'V3' OR A4 = 'V4'
    Image
  2. The following screenshot show that usage of parentheses is not supported in logical expressions.
    Image
  3. The following screenshots show that lowercase and mixed-case queries are not supported
    Image
    Image

Do you have any additional context?
Precedence can be enforced by having the grammar to generate lower precedence operators first and generate higher precedence operators further down the parse tree. Currently, they are being generated at the same level in the grammar which is causing the issues with precedence.
Support for case-agnostic grammar can be supported using fragments.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions