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

ANY and ALL contains their operators #963

Merged
merged 2 commits into from
Sep 7, 2023

Conversation

SeanTroyUWO
Copy link
Contributor

Changes Expr::AllOp and Expr::AnyOp to contain the operator which precedes them, rather than be contained by them. This fixes an issue I had as a polars user: pola-rs/polars#10081.

The rational for this is that despite the order the syntax demands, the conditional operator modifies the behavior of the ANY command, and not vice versa. Similar to NOT as with NOT IN, the negation modifies the behavior of the IN, and the IN is the real operation. In both cases, its more convenient to parse the real operation than the modifier(s).

I did not find any uses the the old ANY or ALL commands in any of DataFusion, LocustDB, Ballista, GlueSQL or Opteryx. This might still briefly break their builds however.

If more unit tests are required, please let me know.

Fixes: #936

…comparison operators which precede them a variation of them.
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the contribution @SeanTroyUWO -- I apologize for the delay in reviewing.

This change also appears to be consistent with postgres any mysql (where the ANY/ALL is part of the comparison expression):

https://www.postgresql.org/docs/current/functions-comparisons.html

9.24.3. ANY/SOME (array)
expression operator ANY (array expression)
expression operator SOME (array expression)

https://dev.mysql.com/doc/refman/8.0/en/any-in-some-subqueries.html

The ANY keyword, which must follow a comparison operator, ...

Another alternative might be to add it directly to Expr::BinaryOp but I think that would be far more disruptive to downstream users so this looks good to me

@alamb alamb merged commit e0afd4b into apache:main Sep 7, 2023
10 checks passed
@SeanTroyUWO
Copy link
Contributor Author

Thank you very much for the contribution @SeanTroyUWO -- I apologize for the delay in reviewing.

This change also appears to be consistent with postgres any mysql (where the ANY/ALL is part of the comparison expression):

https://www.postgresql.org/docs/current/functions-comparisons.html

9.24.3. ANY/SOME (array)
expression operator ANY (array expression)
expression operator SOME (array expression)

https://dev.mysql.com/doc/refman/8.0/en/any-in-some-subqueries.html

The ANY keyword, which must follow a comparison operator, ...

Another alternative might be to add it directly to Expr::BinaryOp but I think that would be far more disruptive to downstream users so this looks good to me

Great, I'll look forward to the next release!

@alamb
Copy link
Contributor

alamb commented Sep 8, 2023

Next release is tracked by #955

ETA in about 2 weeks

serprex pushed a commit to serprex/sqlparser-rs that referenced this pull request Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No support for ANY and ALL use in WHERE
2 participants