Skip to content

Syntax scope requirements for (NOT)EXISTS#355

Draft
afs wants to merge 2 commits intomainfrom
afs/scope-exists
Draft

Syntax scope requirements for (NOT)EXISTS#355
afs wants to merge 2 commits intomainfrom
afs/scope-exists

Conversation

@afs
Copy link
Contributor

@afs afs commented Feb 2, 2026


Preview | Diff

@afs afs requested review from Tpt, hartig, kasei and rubensworks February 2, 2026 16:39
@afs afs marked this pull request as draft February 2, 2026 17:01
@afs afs marked this pull request as ready for review February 2, 2026 17:14
syntax forms `EXISTS {P}` or `NOT EXISTS {P}`,
any variable that is in-scope for `GP` is
also in-scope for all group graph patterns,
basic graph patterns, and paths inside `P`.
Copy link
Member

Choose a reason for hiding this comment

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

"...also in-scope for all group graph patterns, basic graph patterns, and paths inside P"
Does this mean only in-scope if P is precisely a group graph pattern, basic graph pattern, or path?
Or does it allow nesting? E.g. within optional or service?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nesting - any group graph pattern.

The requirement is to include the variables of the current row at the bottom then they get incorporated all the way up to P by the usual rules.

<p>
Syntax forms `EXISTS` or `NOT EXISTS` appear inside
a `FILTER` and filters appear inside group graph patterns.
Let `F` be a syntax form `FILTER`
Copy link
Contributor

Choose a reason for hiding this comment

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

F is not used anywhere after. Is it intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's not intentional. (See Greg's comment).

It is trying to say that scope is modified only for the leaves of the AST that can set variables - BGPs and paths.

From there, the current row variables is in-scope by the usual rules and include the current row.

I'll revise it.

</tbody>
</table>
<p>
Syntax forms `EXISTS` or `NOT EXISTS` appear inside
Copy link
Contributor

@kasei kasei Feb 4, 2026

Choose a reason for hiding this comment

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

This seems overly restrictive in suggesting that (not) exists only appears inside filters (and not other places where expressions can be used).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this change enough?

"inside a FILTER and filters appear inside group graph patterns."
==>
"inside expressions <link to [127] Expression>."

Or something that enumerates the places that expressions occur, filter, AS, ORDER BY, (GROUP BY and HAVING are allow AS).

Copy link
Contributor

Choose a reason for hiding this comment

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

Expression would be good, I think.

@afs afs force-pushed the afs/scope-exists branch from e09d5a4 to 726cb67 Compare February 11, 2026 17:37
@afs afs force-pushed the afs/scope-exists branch from 726cb67 to 058dce0 Compare March 9, 2026 14:54
@afs afs marked this pull request as draft March 9, 2026 14:57
@afs afs force-pushed the afs/scope-exists branch from 058dce0 to 171135a Compare March 9, 2026 18:08
@afs afs force-pushed the afs/scope-exists branch from 171135a to 53b2b57 Compare March 9, 2026 18:20
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.

6 participants