Skip to content

feat(unwind): add UNWIND clause (v0.13) - #18

Open
protosphinx wants to merge 2 commits into
mainfrom
bot/unwind-clause
Open

protosphinx wants to merge 2 commits into
mainfrom
bot/unwind-clause

Conversation

@protosphinx

Copy link
Copy Markdown
Member

Summary

  • Adds UNWIND expr AS var clause to the grammar, AST, planner, cost model, projection pruner, predicate-pushdown optimizer, and semantic analyzer.
  • UNWIND turns a list expression into one output row per element; the element is bound to var. Case-insensitive keyword, blocked from use as an identifier.
  • Cost model uses the literal list length when statically known, defaulting to 10x for dynamic/param lists.
  • sema.rs collects the UNWIND binding and checks the list expression against current scope.
  • 14 new tests in tests/unwind.rs covering parse, plan, cost, and pruning.

Files changed

File Change
src/cypher.pest kw_unwind, unwind_clause, added to reserved_kw and clause
src/ast.rs Clause::Unwind { expr, var }
src/parser.rs walk_unwind, kw_unwind in is_kw
src/plan.rs Plan::Unwind, lowering arm, Display arm
src/cost.rs estimate arm for Plan::Unwind
src/prune.rs walk_output and required_input_columns arms
src/optimize.rs descend and walk_bound arms
src/sema.rs collect_bindings and check_clause arms
tests/unwind.rs 14 new integration tests

Test plan

  • cargo test -- all 200 tests pass (186 existing + 14 new)
  • cargo clippy --all-targets -- -D warnings -- clean
  • cargo fmt --check -- clean
  • No changes to src/lib.rs
  • No new runtime dependencies
  • No .github/workflows changes
  • LOC delta well under 250

🤖 Daily bot


Generated by Claude Code

@protosphinx protosphinx added the automated Opened by the daily bot label Jun 24, 2026 — with Claude

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b677eab14

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/sema.rs Outdated

Copy link
Copy Markdown
Member Author

auto-deferred for human review: LOC delta 298 (295 added + 3 removed) exceeds the 250-line self-merge gate. All CI checks are green; the implementation looks correct. A human reviewer should sanity-check the UNWIND planner/optimizer arms and then merge.


Generated by Claude Code

@protosphinx protosphinx added the needs-review PR awaiting human review label Jun 25, 2026 — with Claude
claude and others added 2 commits August 26, 2026 16:05
Implements UNWIND as a lateral unnest operator: each input row is
cross-applied against the list expression, producing one output row per
list element bound to the named variable. Covers grammar (kw_unwind,
case-insensitive), AST (Clause::Unwind), plan lowering (Plan::Unwind),
cost estimation (literal-length or 10x default), projection pruning,
predicate-pushdown optimizer, and semantic analysis. 14 new tests.
The two-pass approach (collect all bindings, then check all clauses)
pre-collected the UNWIND alias into the binding set before checking the
list expression. This caused UNWIND [x] AS x to be silently accepted
when x had no prior binding, because x was already in scope at
expression-check time.

Replace collect_bindings + global-bindings-pass with a single ordered
pass: check each clause against the scope accumulated so far, then call
extend_scope to add the bindings that clause produces. The UNWIND alias
is now added to scope only after its list expression is validated.

Three new tests in tests/sema.rs cover the self-shadow error case, a
valid MATCH-then-UNWIND-same-name case, and a chained UNWIND case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot needs-review PR awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants