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

Adds ORDER BY #41

Merged
merged 9 commits into from
May 3, 2024
Merged

Adds ORDER BY #41

merged 9 commits into from
May 3, 2024

Conversation

jackboyla
Copy link
Contributor

@jackboyla jackboyla commented May 3, 2024

from grandcypher import GrandCypher
import networkx as nx

host = nx.DiGraph()
host.add_node("a", name="Alice", age=25)
host.add_node("b", name="Bob", age=30)
host.add_node("c", name="Carol", age=25)
host.add_node("d", name="Dave", age=25)

qry = """
MATCH (n)
RETURN n.name 
ORDER BY n.age ASC, n.name DESC
"""
res = GrandCypher(host).run(qry)
# names sorted in descending order where ages are the same

print(res)

# {'n.name': ['Dave', 'Carol', 'Alice', 'Bob']}

also extra test for DISTINCT

Adding ORDER BY requires some slight changes in the order of operations being applied.

Pagination (LIMIT + SKIP) has to wait until all other operations are applied.

Did some refactoring on returns because it was getting pretty big😅

README.md Outdated Show resolved Hide resolved
Copy link
Member

@j6k4m8 j6k4m8 left a comment

Choose a reason for hiding this comment

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

AMAZING stuff, particular kudos for the great inline docs, the thoughtful unittests, and the super helpful error messages when things fail assertions!! THANK YOU!

@j6k4m8
Copy link
Member

j6k4m8 commented May 3, 2024

I'll merge once you claim your very-much-due credit in the readme / changelog :) (Or I can write that up if you prefer not to!)

@jackboyla
Copy link
Contributor Author

cheers! you're too kind :) i'll add my name and let you merge

@j6k4m8 j6k4m8 merged commit 664ab96 into aplbrain:master May 3, 2024
6 checks passed
@jackboyla jackboyla deleted the add-order-by branch May 3, 2024 17:33
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.

2 participants