Skip to content

parser: existential subquery brace form EXISTS { pattern } (+2 TCK) - #86

Merged
dylanbstorey merged 1 commit into
mainfrom
i0339-next5
May 29, 2026
Merged

parser: existential subquery brace form EXISTS { pattern } (+2 TCK)#86
dylanbstorey merged 1 commit into
mainfrom
i0339-next5

Conversation

@dylanbstorey

Copy link
Copy Markdown
Contributor

`MATCH (n) WHERE exists { (n)-->() } RETURN n` (ExistentialSubquery1 [1]/[3]) raised a parse error — only the parenthesized `EXISTS(pattern)` form was accepted, not the openCypher existential-subquery brace form `EXISTS { ... }`.

Fix

Added `EXISTS '{' pattern_list '}'` to the expr grammar, reusing the existing `make_exists_pattern_expr` / `EXISTS_TYPE_PATTERN` transform. That emitter already handles correlated outer variables — the outer-bound `n` resolves via `transform_var_get_alias` and is referenced without being added to the subquery FROM, producing `EXISTS (SELECT 1 FROM ... WHERE ...)`.

No bison conflicts (still `%expect 15` / `%expect-rr 3`).

Scope

No-inner-WHERE form only. The brace form with an inner WHERE ([2]/[4]) and the full-query / aggregation / nested forms (ExistentialSubquery2/3) need inner-variable registration in the subquery scope — deferred to a follow-up.

Verification

Fixes ExistentialSubquery1 [1] and [3]. Zero TCK regressions (fail steady at 132). 3708 → 3710. Unit 944/944, functional clean.

`MATCH (n) WHERE exists { (n)-->() } RETURN n` (ExistentialSubquery1 [1]/[3])
raised a parse error — only the parenthesized `EXISTS(pattern)` form was
accepted, not the openCypher existential-subquery brace form `EXISTS { ... }`.

Added `EXISTS '{' pattern_list '}'` to the expr grammar, reusing the existing
`make_exists_pattern_expr` / `EXISTS_TYPE_PATTERN` transform. That emitter
already handles correlated outer variables (the outer-bound `n` resolves via
transform_var_get_alias and is referenced without being added to the subquery
FROM), producing `EXISTS (SELECT 1 FROM ... WHERE ...)`.

No bison conflicts (still `%expect 15` / `%expect-rr 3`).

Scoped to the no-inner-WHERE form. The brace form with an inner WHERE
([2]/[4]) and the full-query / aggregation / nested forms
(ExistentialSubquery2/3) need inner-variable registration in the subquery
scope and are deferred.

Fixes ExistentialSubquery1 [1] and [3]. Zero TCK regressions. 3708 -> 3710.
Unit 944/944, functional clean.
@dylanbstorey
dylanbstorey merged commit f04b1aa into main May 29, 2026
17 checks passed
@dylanbstorey
dylanbstorey deleted the i0339-next5 branch May 29, 2026 02:38
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.

1 participant