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

Feature Request: Support for ANY Clause in WHERE for List Filtering #51

Open
SDJohn-sudo opened this issue Nov 1, 2024 · 4 comments
Open
Labels
enhancement New feature or request language

Comments

@SDJohn-sudo
Copy link

Thank you for your work on this project!
I am suggest a feature that would greatly enhance the flexibility of this library.

Feature Request:

I would like to request the addition of support for the ANY clause within WHERE conditions. Specifically, the goal is to allow filtering over a list of dictionaries (e.g., [{key: value}, {key: value}]) to check if any element within the list meets a given condition.

Current Situation:

At the moment, I am working with data structured as lists of dictionaries, and there doesn’t seem to be a way to use the WHERE clause effectively to filter and return items based on whether any element in such lists meets certain criteria.

Example Scenario:

MATCH (n:NodeLabel)
WHERE ANY(item IN n.listProperty WHERE item.key1 = "specificValue")
RETURN n

Benefit of the Feature:
Adding this functionality would provide users the ability to:

•	Perform more complex and expressive queries involving lists and nested data structures.
•	Enhance the ability to filter and return results based on conditions within list properties.
@j6k4m8
Copy link
Member

j6k4m8 commented Nov 1, 2024

This is great, thank you for the request and thoughtful context!

Adding this to the features roadmap for sure!! Unfortunately I don't have an idea of when this will become available, but this does seem like a great feature for us to support here.

@j6k4m8 j6k4m8 added enhancement New feature or request language labels Nov 1, 2024
@SDJohn-sudo
Copy link
Author

Thank you for your response!
I also had tried to implement this functionality myself but ran into some challenges with this lib processing logic.

If you could provide some guidance or insight into how the code operates, I would be more than happy to give it another shot.

@j6k4m8
Copy link
Member

j6k4m8 commented Nov 4, 2024

So I can imagine "proper" addition of this to the language, which would involve a new grammar addition... Or maybe a cheating version: we could think about this is by "unrolling" the array into a where X₁ or X₂ or X₃ or ...

But to do "the right thing," here's a sketch:

  • Update the grammar support for compound_clause to also allow ANY() and ALL()
  • Create a new function in the transformer (taking inspiration from the existing boolean logic operations) to catch these and "unroll" them into chained ANDs or ORs (I need to think a bit more about performance characteristics of doing this... but I THINK it's mostly harmless)
  • Transparently call into the existing infix boolean logic operations like or to reuse our existing support for these

Let me know if this is a helpful pointer?

If not, maybe I'll have some time in the next few weeks to take a crack at this too :)

@SDJohn-sudo
Copy link
Author

Thanks! This is really helpful hint.
I will work on developing this feature.

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

No branches or pull requests

2 participants