Skip to content

feat: support COUNT(DISTINCT expr) in Cypher queries#116

Merged
beinan merged 1 commit into
lance-format:mainfrom
ChunxuTang:count-distinct
Jan 30, 2026
Merged

feat: support COUNT(DISTINCT expr) in Cypher queries#116
beinan merged 1 commit into
lance-format:mainfrom
ChunxuTang:count-distinct

Conversation

@ChunxuTang

@ChunxuTang ChunxuTang commented Jan 30, 2026

Copy link
Copy Markdown
Collaborator

This PR:

  • Adds support for COUNT(DISTINCT x) aggregation in Cypher queries
  • Introduces proper AST distinction between scalar and aggregate functions (similar to the handling in DataFusion)
  • Validates COUNT(DISTINCT *) is rejected with a helpful error message

Fix #108

Example:

MATCH (p:Person)-[:workAt]->(o:Organisation)
RETURN COUNT(DISTINCT p.id) AS num_employees, o.id
ORDER BY num_employees DESC

@prrao87

prrao87 commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Exciting! Thanks for implementing 😁. This will unlock 10 queries in the LDBC benchmark suite!

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.61224% with 23 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/lance-graph/src/semantic.rs 90.09% 11 Missing ⚠️
crates/lance-graph/src/parser.rs 87.93% 7 Missing ⚠️
...s/lance-graph/src/datafusion_planner/expression.rs 93.54% 4 Missing ⚠️
crates/lance-graph/src/simple_executor/expr.rs 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@beinan beinan merged commit d3ec359 into lance-format:main Jan 30, 2026
9 checks passed
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.

Unable to COUNT(DISTINCT x) on nodes

4 participants