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

Support for PIPE operator for apache-age-python client #865

Open
czesiu89 opened this issue Apr 27, 2023 · 17 comments
Open

Support for PIPE operator for apache-age-python client #865

czesiu89 opened this issue Apr 27, 2023 · 17 comments
Labels
enhancement New request override-stale To keep issues/PRs untouched from stale action

Comments

@czesiu89
Copy link

Currently we are running queries that require several Relationship (age.models.Edge) types to be filtered out.
We tried to approach it with OPTIONAL MATCH but it didn't suite as too well, since it requires first statement to have matches to process with the other.
Ended up with something like "MATCH ()-[r]-() WHERE r.type in ["type1", "type2"] RETURN r".
In OpenCypher specs there is a mention about PIPE operator that facilitates such OR statements for relationship types and it goes like: "MATCH ()-[r:type1|type2]-() RETURN r.
It feels a lot more natural to use. This one gives us "syntax error near |'.

Are there any plans to implement such operator or is it somehow limited?

@czesiu89 czesiu89 added the enhancement New request label Apr 27, 2023
@farakh-shahid
Copy link

Yes PIPE is cutoff. It is no more supported for specifying relationship types in single pattern.

But after checking some doc have you tried using WHERE clause with IN
I think this might WORK
like
WHERE r.type IN ['type1', 'type2']

@cvanlabe
Copy link

@farakh-shahid That is exactly what @czesiu89 is saying he's using as workaround, indeed.

Is there any reason why PIPE is "no more supported"? Does it imply that Age is not implementing 100% OpenCypher? As I believe it's part of its grammar?

Thanks a lot!

@eyab
Copy link
Member

eyab commented Aug 22, 2023

Hi @czesiu89 Any new updates on this? Can you share a bit more about your use-case? It'll help us prioritize.

@pawankukreja01
Copy link

The PIPE operator is a feature of the Nebula Graph Query Language (nGQL) and is not part of OpenCypher. It allows multiple queries to be combined using pipe operators in nGQL. The PIPE operator applies to native nGQL only and is not compatible with OpenCypher

@jrgemignani
Copy link
Contributor

@cvanlabe -

@farakh-shahid That is exactly what @czesiu89 is saying he's using as workaround, indeed.

Is there any reason why PIPE is "no more supported"? Does it imply that Age is not implementing 100% OpenCypher? As I believe it's part of its grammar?

Thanks a lot!

Can you please show me where in the openCypher documentation it states the pipe operator was/is supported?

@cvanlabe
Copy link

@jrgemignani thanks for your response. As I mentioned, it’s visible in the grammar I linked to.

In the documentation, it’s described as early as page 10 in the opencypher reference:

” if we’d like to describe some data such that the relationship could have any one of a set of types, then they can all be listed in the pattern, separating them with the pipe symbol | like this:”

(a)-[r:TYPE1|TYPE2]->(b)

@jrgemignani
Copy link
Contributor

I will bring this "oversight" up with the team and see if we can get it added. @rafsun42 @dehowef @muhammadshoaib

@jrgemignani
Copy link
Contributor

jrgemignani commented Oct 16, 2023

Btw, the title for this issue is a bit misleading. This issue is for adding the OR operator | to the language for the edge match.

@rafsun42
Copy link
Member

rafsun42 commented Oct 16, 2023

@czesiu89 @cvanlabe The work on this operator is currently in progress. It would be useful if you let us know your data model and queries.

@cvanlabe
Copy link

Thanks so much everyone! We can't immediately share our data model we use today. Assume it's a typical graph, which has several nodes connected to other nodes where each connection is a different relation type.
Using the OR operator, we can decide which nodes we want to visualize given the used relationships.

I hope this helps.

@thjbdvlt
Copy link

thjbdvlt commented Feb 6, 2024

hi, i face a situation where the pipe-OR operator would be usefull, so as my situation is pretty simple i describe it here.

this is the query i tried, in which i want to match synonyms or hyperonyms of a word, and synonym/hyperonyms of synonym/hyperonyms, and synonym/hyperonyms of synonym/hyperonym of synonym/hyperonym of this word (including pattern like: synonym -> hyperonym -> synonym, and so on). so i need variable-length edges and the OR operator.

select * from cypher('graph_dict', $$
    match (s:word {graphic_form: 'know'})-[r:has_synonym|has_hyperonym|has_holonym *1..3]->(t:word)
    return s, t
$$) as (source agtype, target agtype);

with the solution proposed in the beginning of this discussion, it produces an error. this is what i've tried:

select * from cypher('graph_dict', $$
    match (s:word {graphic_form: 'know'})-[r]->(m:word)-[s *0..2]->(t:word)
    where label(r) in ['has_synonym', 'has_hyperonym', 'has_holonym']
    and label(s) in ['has_synonym', 'has_hyperonym', 'has_holonym']
    return l.id, t.graphie
$$) as (source agtype, target agtype);

the error is the following, and it seems that when the second edge is length 0, label() cannot be used (obviously).

ERROR: label() argument must resolve to a vertex or an edge.

my data structure is very simple: vertices are words (with a graphic_form and an id) and edges are relations between these words (has_synonym, has_antonym, has_hyperonym, ...).

@rafsun42
Copy link
Member

rafsun42 commented Feb 6, 2024

@thjbdvlt PR #1452 implements multiple label support. It has not been approved yet, but you can try it out.

@thjbdvlt
Copy link

thjbdvlt commented Feb 7, 2024

@rafsun42 thank you! i am currently on PG15 so i cannot compile with it (PR 1452), but i'll try to upgrapde to PG16 soon so i can try it out, because it seems to be what i need! :)

@rafsun42
Copy link
Member

rafsun42 commented Feb 7, 2024

@thjbdvlt The PR 1452 is actually based on PG15. Do you get a compilation error?

@thjbdvlt
Copy link

thjbdvlt commented Feb 8, 2024

@rafsun42 unfortunately: yes! but as i am really not a programmer, i have no doubts: it must be because of me not understanding something. anyway, i post a comment directly on the PR 1452 page with logs and description of what i have done, just in case it may help!

Copy link

This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Stale issues/PRs label May 11, 2024
@jrgemignani jrgemignani removed the Stale Stale issues/PRs label May 14, 2024
Copy link

This issue is stale because it has been open 60 days with no activity. Remove "Abondoned" label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale Stale issues/PRs label Jul 14, 2024
@MuhammadTahaNaveed MuhammadTahaNaveed added override-stale To keep issues/PRs untouched from stale action and removed Stale Stale issues/PRs labels Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New request override-stale To keep issues/PRs untouched from stale action
Projects
None yet
Development

No branches or pull requests

9 participants