-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
EQL: ambiguous syntax for chained predicates #61654
Comments
Pinging @elastic/es-ql (:Query Languages/EQL) |
Update: I think this is actually okay in its current implementation. It's not a bug then, more of a specification question. I looked into this a little bit more, and I think that the expectation for many languages is for the equality operator to be left-associative. Thus I think it comes to a matter of specification, and what we think is desired behavior for the language. Do we want this operator to be left-associative or do we want to forbid this syntax? We can decide the ideal specification, and from there we can work out the implementation details, if any need to be changed. I added the label |
Just listing the behaviour of SQL in some popular DBs:
MySQL:
Oracle gives a syntax error for those expressions. I have no real personal preference, I'd say to keep it as is (left-associative) rather than forbid it. |
Expressions like `1 = 2 = 3 = 4` or `1 < 2 = 3 >= 4` were treated with leftmost priority: ((1 = 2) = 3) = 4 which can lead to confusing results. Since such expressions don't make so much change for EQL filters we disallow them in the parser to prevent unexpected results from their bad usage. Major DBs like PostgreSQL and Oracle also disallow them in their SQL syntax. (counter example would be MySQL which interprets them as we did before with leftmost priority). Fixes: elastic#61654
Expressions like `1 = 2 = 3 = 4` or `1 < 2 = 3 >= 4` were treated with leftmost priority: ((1 = 2) = 3) = 4 which can lead to confusing results. Since such expressions don't make so much change for EQL filters we disallow them in the parser to prevent unexpected results from their bad usage. Major DBs like PostgreSQL and Oracle also disallow them in their SQL syntax. (counter example would be MySQL which interprets them as we did before with leftmost priority). Fixes: #61654
Expressions like `1 = 2 = 3 = 4` or `1 < 2 = 3 >= 4` were treated with leftmost priority: ((1 = 2) = 3) = 4 which can lead to confusing results. Since such expressions don't make so much change for EQL filters we disallow them in the parser to prevent unexpected results from their bad usage. Major DBs like PostgreSQL and Oracle also disallow them in their SQL syntax. (counter example would be MySQL which interprets them as we did before with leftmost priority). Fixes: #61654 (cherry picked from commit 8f94981)
Existing implementations of EQL have peg-based grammars, and as part of the design can't support chaining predicates.
For example,
1 == 1 == 1
raises a syntax error. This seems like good behavior, forcing the user to do(1 == 1) == 1
.Then you get this
However, for Elasticsearch, we accept this syntax. But it's not clear what it means.
(I think there's another issue here with data type validation isn't detecting a type mismatch with
(bool) == long
The text was updated successfully, but these errors were encountered: