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

[openCypher tck case] with/match aliases conflict #2696

Closed
czpmango opened this issue Jan 21, 2021 · 1 comment
Closed

[openCypher tck case] with/match aliases conflict #2696

czpmango opened this issue Jan 21, 2021 · 1 comment
Labels
type/feature req Type: feature request

Comments

@czpmango
Copy link
Contributor

neo4j test:

neo4j@neo4j> WITH null AS a   MATCH p = (a)-[r]->() RETURN 1;
+---+
| 1 |
+---+
+---+

neo4j@neo4j> WITH null AS a   optional MATCH p = (a)-[r]->() RETURN 1;
+---+
| 1 |
+---+
| 1 |
+---+

nebula test:

(czp@nebula) [nba]> WITH null AS a   MATCH p = (a)-[r]->() RETURN 1;;
[ERROR (-12)]: SemanticError: `a': Redefined alias
@czpmango czpmango changed the title [openCypher tck case] with/match aliases [openCypher tck case] with/match aliases conflict Jan 21, 2021
@czpmango
Copy link
Contributor Author

czpmango commented Jan 21, 2021

For the case where aliases refer to each other between multiple match/with clauses, I conducted the following sets of neo4j tests:

test case1:

with "Tony Parker" as a match (v:player{name: a}) return v
  • The previously defined alias can be normally quoted by subsequent with/match clauses.

test case2:

query1: match (v:player{name:"Tim Duncan"}) with v as a match (a:player{name:"Tony Parker"})-[]-(b) match (q:team) return b,q
query2: match (v:player) with v as a match (a:player{name:"Tony Parker"})-[]-(b) match (q:team) return b,q

query1 result : empty
query2 result : not empty

  • The execution plans of query1 and query2 are exactly the same, and the result of query1 is empty. The subsequent match clause in the execution plan is executed as a filter.

test case3:

match (v:player) with v as a,v as v match (a:player{name:"Tony Parker"})-[]-(b)  return a,count(*)
match (v:player) with v as a,v as v match (a:player{name:"Tony Parker"})-[]-(b)  return v,count(*)
match (v:player) with v as a,v as v match (a:player{name:"Tony Parker"})-[]-(b)  match (a:player) return v,count(*)

The results of the above queries are all the same.

  • This test scenario proves that alias is reference logic rather than copy logic, and it is global logic rather than clause logic.

test case4:

query1: match (v:player{name:"Tony Parker"}) with v as a match p=(o:player{name:"Tim Duncan"})-[]->(a) return o,p
query2: match (v:player{name:"Tony Parker"}) with v as a match p=(o:player{name:"Tim Duncan"})-[]->(a:player) return o,p
query3: match (v:player{name:"Tony Parker"}) with v as a match p=(o:player{name:"Tim Duncan"})-[]->(a:team) return o,p
query4: match (v:player{name:"Tony Parker"}) with v as a match p=(o:player{name:"Tim Duncan"})-[]->(x:team) return o,p
query5: match (v:player{name:"Tony Parker"}) with v as a match p=(o:player{name:"Tim Duncan"})-[]->(a:team{name:"Spurs"}) return o,p

query1/query2 result: one row
query3/query5 result: empty (no error!)
query4 result: one row

  • This test scenario proves that alias A can be defined repeatedly, but illegal repeated definitions will not produce expected behavior.

test case5:

query1: query1: match (v:player) with v as a,v as v match (a:player{name:"Tony Parker"})-[]-(b) create (x:player{name:"x",age:32}) match (v:player) as a  return a,count(*)
query2: match (v:player) with v as a,v as v match (a:player{name:"Tony Parker"})-[]-(b) create (x:player{name:"x",age:32}) with (v:player) as a  return a,count(*)
query3: match (v:player) with v as a,v as v match (a:player{name:"Tony Parker"})-[]-(b) create (x:player{name:"x",age:32}) with labels(a)=["player"] as a  return a,count(*)
query4: match (v:player) with v as a,v as v match (a:player{name:"Tony Parker"})-[]-(b) create (x:player{name:"x",age:32}) with (v:player) as a match (y:player) return y,a,count(*)

query1 result: error
query2/query3 result: alias a is a bool value!!!
query4 result: y is new match result

@CPWstatic CPWstatic transferred this issue from vesoft-inc/nebula-graph Aug 28, 2021
@CPWstatic CPWstatic added the type/feature req Type: feature request label Aug 28, 2021
@czpmango czpmango closed this as completed Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature req Type: feature request
Projects
None yet
Development

No branches or pull requests

2 participants