Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on Semantics of WITH clause #568

Open
ddaa2000 opened this issue Nov 17, 2023 · 1 comment
Open

Question on Semantics of WITH clause #568

ddaa2000 opened this issue Nov 17, 2023 · 1 comment

Comments

@ddaa2000
Copy link

I find that the Open-Cypher Specification for the WITH clause is a little unclear. Specifically, I'm not sure how the WITH clause deals with the result set of the previous clause if the WITH clause is a "WITH expr as a" (expr is not an aggregation function).
Specifically, for the empty result set from the previous clause. Should "WITH 1 as a" return a line of 1, or no line, or this is an undefined behavior?

Thanks a lot!

@Hunterness
Copy link

A query like

MATCH (n) 
WITH 1 AS a
RETURN a

on an empty graph will return nothing as the result of the MATCH is empty.

The OpenCypher documentation does not explain this very well, but the linear composition means that the WITH clause will receive the output of the last clause as input and apply it's usage on each row of that input (unless aggregation is involved). If it receives 0 rows then it will apply it's 1 as a zero times and also give back 0 rows to the next clause.

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

No branches or pull requests

2 participants