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

Cypher grammar fails to parse call subqueries. #3544

Open
rvrooman-codelogic opened this issue Jun 20, 2023 · 6 comments
Open

Cypher grammar fails to parse call subqueries. #3544

rvrooman-codelogic opened this issue Jun 20, 2023 · 6 comments
Labels

Comments

@rvrooman-codelogic
Copy link
Contributor

Example:

MATCH (n1:Label1 { id: $id })
CALL {
    WITH n1
    MATCH (n1)-[:REFERENCES]->(n2:Label2)
    SET n2.deleted = true
}
DETACH DELETE n1

Is valid syntax with a valid 'EXPLAIN' for Neo4j version 4.4.21

The Parser resulted in:

line 2:5 no viable alternative at input 'MATCH (n1:Label1 { id: id })\nCALL {
@kaby76
Copy link
Contributor

kaby76 commented Jun 21, 2023

The project website for Cypher already publishes a combined grammar. I don't understand why this grammar was split and symbols renamed. The description on the initial commit is the empty string (typical for the grammars-v4 project). I suspect the splitting may be for the caseInsensitive option. If that is true, then a Trash script should be applied to the scraped grammar from the official website, so this can be an automate process to update with new releases.

@KvanTTT KvanTTT added the cypher label Jun 21, 2023
@KvanTTT
Copy link
Member

KvanTTT commented Jun 21, 2023

I suspect the splitting may be for the caseInsensitive option.

The caseInsensitive option is supported in combined grammars as well.

@kaby76
Copy link
Contributor

kaby76 commented Jun 21, 2023

I suspect the splitting may be for the caseInsensitive option.

The caseInsensitive option is supported in combined grammars as well.

Hmm. Maybe for the channel option? The official grammar places white space on the default channel.

@rvrooman-codelogic
Copy link
Contributor Author

rvrooman-codelogic commented Jun 21, 2023

Thanks for the quick responses. I was unaware that there was an official grammar released for Cypher. That may help with my project.

In any case, I am writing a few unit tests for the Parser when integrated into our software and found another issue with the version of the grammar in this repository.

Update: There is an issue open with the OpenCypher grammar related to function invocations in which there is a reserved word. It is not specific to the grammar in this repository.

opencypher/openCypher#552


The example:

RETURN apoc.create.uuid()

Is not being treated as a procedure call. It also misunderstands 'CREATE' as a reserved word in the above script.
image

Resulting error:

line 1:23 mismatched input '(' expecting {<EOF>, ';'}

Not sure what 'Trash script' means in this context, but I could potentially submit a PR once it is determined why the grammar was split and what the path forward is.

@kaby76
Copy link
Contributor

kaby76 commented Jun 21, 2023

Not sure what 'Trash script' means in this context, but I could potentially submit a PR once it is determined why the grammar was split and what the path forward is.

Trash is my toolkit for Antlr grammars. It can do a lot of different things, including generate parser drivers, check coverage of the tests on the grammar, perform "grouped" and "individual" parsing, search for problems in grammars, do performance testing, rename symbols, refactor rules, etc. The grammar was split because the comments are placed on a named channel. That cannot be done when the grammar is a combined lexer/parser grammar. I'm not sure what best to do yet because I'd like to see how the official grammar performs. Do the tests parse?

@rvrooman-codelogic
Copy link
Contributor Author

rvrooman-codelogic commented Jun 21, 2023

I'm not sure what best to do yet because I'd like to see how the official grammar performs. Do the tests parse?

Both tests fail to parse with the official grammar for OpenCypher.
The example this issue was opened with does not seem to fit the specification for OpenCypher version 9 (CALL..YIELD pg 122). There is no mention of subqueries in a CALL clause in the specification.

This is, however, valid Cypher and can be executed against Neo4j. Call Subquery Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants