Skip to content

feat: EXISTS subquery support (simple, nested, with WHERE) #385

@DecisionNerd

Description

@DecisionNerd

Problem

EXISTS subqueries (WHERE EXISTS { MATCH ... }) are not implemented. Queries using this syntax either fail to parse or execute incorrectly.

Remaining TCK Failures (as of Phase 9, 7 scenarios)

test_simple_subquery_without_where_clause
test_simple_subquery_without_where_clause_not_existing_pattern
test_simple_subquery_with_where_clause
test_simple_subquery_with_where_clause_not_existing_pattern
test_nested_simple_existential_subquery
test_nested_full_existential_subquery_with_pattern_predicate
test_full_existential_subquery_with_update_clause_should_fail

Failure Details

  1. Simple EXISTS without WHERE (2): WHERE EXISTS { MATCH (n)-->(m) }
  2. Simple EXISTS with WHERE (2): WHERE EXISTS { MATCH (n)-->(m) WHERE m.prop = 'x' }
  3. Nested EXISTS (1): EXISTS inside EXISTS
  4. EXISTS with pattern predicate (1): WHERE EXISTS { (n)-[:R]->(m) } combined with other predicates
  5. EXISTS with update clause should fail (1): EXISTS { CREATE (n) } should raise SyntaxError at compile time

Layers Affected

All four: grammar (cypher.lark), AST (ast/), planner (planner.py), executor (executor.py / evaluator.py).

Acceptance Criteria

  • WHERE EXISTS { MATCH (n)-->(m) } evaluates to true/false correctly
  • WHERE EXISTS { MATCH (n)-->(m) WHERE m.active = true } filters by subquery condition
  • Nested EXISTS { EXISTS { ... } } evaluates correctly
  • EXISTS { CREATE (n) } raises SyntaxError at compile time

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions