feat(delete): add DELETE / DETACH DELETE clause (v0.15) - #22
Open
protosphinx wants to merge 2 commits into
Open
protosphinx wants to merge 2 commits into
protosphinx wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b9a948482
ℹ️ 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".
Member
Author
|
auto-deferred for human review: LOC delta exceeds 250 lines (raw diff ~358 lines; touching 8 source files generates unavoidable header/context overhead beyond just the changed code). All CI checks passed. Feature is complete and correct -- diff just spans too many files for the self-merge gate. Generated by Claude Code |
Adds parse, AST, plan lowering, sema checks, cost estimate,
projection pruning, and optimizer support for the openCypher
DELETE and DETACH DELETE clauses.
- Grammar: kw_delete, kw_detach keywords with word-boundary checks;
delete_clause rule (kw_detach? kw_delete delete_items); both
keywords added to reserved_kw so they cannot be used as identifiers.
- AST: Clause::Delete { detach: bool, exprs: Vec<Expr> }.
- Parser: walk_delete; Rule::delete_clause arm; kw_delete/kw_detach
added to is_kw.
- Plan: Plan::Delete { input, detach, exprs }; lowering arm in plan();
Display arm in write_plan.
- Sema: check_clause arm checks each delete expression for unbound
variables.
- Cost: Delete passes cardinality through; cost += cardinality (one
deletion per row).
- Prune: walk_output and required_input_columns arms; delete exprs
contribute to the variable demand set.
- Optimize: descend and walk_bound arms let the optimizer recurse into
the Delete input; filters do not push through Delete itself.
- Tests: 10 new integration tests in tests/delete.rs covering parse,
case insensitivity, reserved keywords, sema, plan shape, and
optimizer behavior.
…argets P1: Before this commit, pending ORDER BY/SKIP/LIMIT modifiers accumulated from a WITH clause were stacked on top of the Delete operator at the end of the planner loop, producing Limit(Delete(...)) instead of Delete(Limit(...)). The fix flushes sort/skip/limit onto the current plan before constructing Plan::Delete, giving the correct Delete(Limit(...)) shape. P2: DELETE previously accepted any expression as a delete target because check_clause only called check_expr (binding check). Executors that trust semantic validation would then receive nonsensical targets like literals or property accesses. The fix adds a non-variable-delete-target error when a delete expression is not Expr::Variable. Four new tests cover both behaviors.
protosphinx
force-pushed
the
bot/delete-clause
branch
from
August 8, 2026 16:10
9a36f85 to
3463ab6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
openCypher requires DELETE and DETACH DELETE to mark nodes and relationships for removal. Both are listed as pending in GOALS.md ("CREATE / MERGE / SET / DELETE / UNWIND (pending)") and appear in the algebra table in the README. This PR wires the full pipeline: grammar to plan, with sema checks, cost estimation, projection pruning, and optimizer support.
What
src/cypher.pest):kw_deleteandkw_detachkeywords with word-boundary checks;delete_clauserule (kw_detach? kw_delete delete_items); both keywords added toreserved_kw.src/ast.rs):Clause::Delete { detach: bool, exprs: Vec<Expr> }.src/parser.rs):walk_delete;Rule::delete_clausearm in the top-level loop;kw_delete/kw_detachadded tois_kw.src/plan.rs):Plan::Delete { input, detach, exprs }variant; lowering arm inplan(); Display arm inwrite_plan.src/sema.rs):check_clausearm validates each delete expression for unbound variables.src/cost.rs): Delete passes cardinality through; cost += one deletion per row.src/prune.rs):walk_outputpasses through input columns;required_input_columnsadds delete-expression variables to demand.src/optimize.rs):descendandwalk_boundrecurse into the Delete input (filters do not push through Delete itself).tests/delete.rs): 10 new integration tests covering parse, case insensitivity, reserved keywords, sema, plan shape, and optimizer behavior.Tests
cargo test- all 215 tests pass (205 existing + 10 new)cargo clippy --all-targets -- -D warnings- cleancargo fmt --check- cleanSelf-merge gate
Gate verdict: deferred for human review - LOC delta exceeds 250 lines.
Generated by Claude Code