Skip to content

Support Simple Unwind in lance-graph#112

Merged
ChunxuTang merged 7 commits into
lance-format:mainfrom
leiyuou:yuolei/unwind
Jan 29, 2026
Merged

Support Simple Unwind in lance-graph#112
ChunxuTang merged 7 commits into
lance-format:mainfrom
leiyuou:yuolei/unwind

Conversation

@leiyuou

@leiyuou leiyuou commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Support
UNWIND [1, 2, 3] AS num RETURN num
MATCH (n) UNWIND n.list AS item RETURN item
MATCH (p:Person) UNWIND [10, 20] AS x RETURN p.name, x
UNWIND [1, 2] AS target_id MATCH (p:Person) WHERE p.id = target_id RETURN p.name

Key changes:

  1. Merged UNWIND and MATCH clauses into unified reading_clauses since In Cypher, MATCH and UNWIND can appear in any order
  2. Added ReadingClause and UnwindClause enum to AST
  3. Updated Parser to handle mixed MATCH/UNWIND clauses
  4. Added Logical Plan operator for UNWIND
  5. Implemented DataFusion execution for UNWIND

@codecov-commenter

codecov-commenter commented Jan 28, 2026

Copy link
Copy Markdown

@beinan beinan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm, @ChunxuTang do you want also take a look? thanks!

@ChunxuTang ChunxuTang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@leiyuou
Generally looks good to me! Just left a minor comment.

Comment on lines +4514 to +4533
// Parser Tests

#[test]
fn test_parse_unwind_simple() {
use lance_graph::parser::parse_cypher_query;
let query = "UNWIND [1, 2, 3] AS num RETURN num";
let ast = parse_cypher_query(query);
assert!(ast.is_ok(), "Failed to parse simple UNWIND query");
}

#[test]
fn test_parse_unwind_after_match() {
use lance_graph::parser::parse_cypher_query;
let query = "MATCH (n) UNWIND n.list AS item RETURN item";
let ast = parse_cypher_query(query);
assert!(ast.is_ok(), "Failed to parse UNWIND after MATCH");
}

// Execution Tests

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since the test_datafusion_pipeline.rs mainly contains integration tests, I suggest removing the parser tests from here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If you want to test parsing the UNWIND statements, better to run the tests in the parser.rs file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing it out. Update the PR

@ChunxuTang

Copy link
Copy Markdown
Collaborator

Fix #75

@ChunxuTang ChunxuTang merged commit c8d1069 into lance-format:main Jan 29, 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.

4 participants