You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cypher: DISTINCT applied after ORDER BY + LIMIT instead of before (execution order bug) #237
RETURN DISTINCT ... ORDER BY ... LIMIT N returns far fewer rows than it should because DISTINCT is applied AFTER ORDER BY + LIMIT instead of before. In standard Cypher (openCypher spec), DISTINCT is part of the RETURN projection and must be evaluated BEFORE ORDER BY → SKIP → LIMIT.
Minimal reproducer
In a graph with ~72 distinct Swift files indexed, each containing ~30 symbol nodes:
MATCH (n) WHEREn.file_pathENDSWITH'.swift'RETURNDISTINCTn.file_pathASpathORDER BYpathLIMIT100
Expected: up to 72 rows (all distinct Swift file paths). Actual: only ~5 rows — the alphabetically earliest files. The top 100 rows by file_path ASC come entirely from the first 5 files (each has >20 nodes), and DISTINCT applied to those 100 yields only ~5 distinct paths.
Removing ORDER BY makes it work correctly:
MATCH (n) WHEREn.file_pathENDSWITH'.swift'RETURNDISTINCTn.file_pathASpathLIMIT100
Verified working on current main — added a regression test that executes RETURN DISTINCT … ORDER BY … LIMIT (DISTINCT applied before ordering/limit) against an in-memory store and asserts the expected result/columns (passes in the full suite). Closing as resolved; please reopen with a concrete failing query if you still hit this on v0.7.0. 🙏
Activity
DeusData commentedon May 31, 2026
Verified working on current
main— added a regression test that executesRETURN DISTINCT … ORDER BY … LIMIT (DISTINCT applied before ordering/limit)against an in-memory store and asserts the expected result/columns (passes in the full suite). Closing as resolved; please reopen with a concrete failing query if you still hit this on v0.7.0. 🙏test(cypher): regression guards for DeusData#240/DeusData#237/DeusDat…