support openCypher-like relationsiop-type edge alternation#2468
Open
eeshwarg wants to merge 1 commit into
Open
support openCypher-like relationsiop-type edge alternation#2468eeshwarg wants to merge 1 commit into
eeshwarg wants to merge 1 commit into
Conversation
Apache AGE's MATCH grammar rejects openCypher's relationship-type alternation syntax -
`MATCH ()-[:A|B]->()` fails at parse time with `syntax error at or near "|"`. For example,
a query like `SELECT * FROM cypher('kg_s7', $$ MATCH (p)-[:WORKS_AT|REPORTS_TO]->(c) RETURN c $$) AS (c agtype);`
throws a syntax error. A workaround for this today is to run something like
`SELECT * FROM cypher('kg_s7', $$ MATCH (p)-[r]->(c) WHERE type(r) IN ['WORKS_AT','REPORTS_TO'] RETURN c $$) AS (c agtype);`.
This change enables support for relationship-type alternation in accordance with the openCypher
standard. Changes are made in the grammar, AST and during transformation from the AST to Postgres
`Query` struct by adding the types to the `quals` list.
Variable-length relationship patterns with alternation `([:A|B*1..2])` are explicitly rejected
with `ERRCODE_FEATURE_NOT_SUPPORTED`.
Testing:
- Added regress test with cases with directed/undirected edges, and variable length edges
Future work:
- openCypher also support node-type alternation (like n:Person|Customer), which could be
added to AGE in a future PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apache AGE's MATCH grammar rejects openCypher's relationship-type alternation syntax -
MATCH ()-[:A|B]->()fails at parse time withsyntax error at or near "|". For example, a query likeSELECT * FROM cypher('kg_s7', $$ MATCH (p)-[:WORKS_AT|REPORTS_TO]->(c) RETURN c $$) AS (c agtype);throws a syntax error. A workaround for this today is to run something likeSELECT * FROM cypher('kg_s7', $$ MATCH (p)-[r]->(c) WHERE type(r) IN ['WORKS_AT','REPORTS_TO'] RETURN c $$) AS (c agtype);.This change enables support for relationship-type alternation in accordance with the openCypher standard. Changes are made in the grammar, AST and during transformation from the AST to Postgres
Querystruct by adding the types to thequalslist.Variable-length relationship patterns with alternation
([:A|B*1..2])are explicitly rejected withERRCODE_FEATURE_NOT_SUPPORTED.Testing:
Future work: