ftsrg / ingraph

Incremental view maintenance for openCypher graph queries.
http://docs.inf.mit.bme.hu/ingraph/
Eclipse Public License 1.0
47 stars 10 forks source link

Path pattern with exact length is misinterpreted #344

Closed marci543 closed 5 years ago

marci543 commented 5 years ago

The exact length of a path pattern (e.g. in MATCH ()-[*2]-()) is misinterpreted as lower bound in the following test case: https://github.com/FTSRG/ingraph/blob/4119811a0e53ef5d6103060f19de97e25813370a/cypher-to-sql/src/test/scala/ingraph/compiler/sql/CompileSqlTest.scala#L447-L459 It produces the following GPlan:

GPlan:
------
'Production
+- 'Projection [ret(v(x, {}, false, (x#0)), None, (x#0))]
   +- 'AllDifferent [edgelistattribute(_e0, {CONTAINS}, true, (2), None, (_e0#0))]
      +- 'Expand v(a, {}, (name,A), false, (a#0)), v(x, {}, false, (x#0)), edgelistattribute(_e0, {CONTAINS}, true, (2), None, (_e0#0)), Out
         +- 'Selection (p(name, v(a, {}, false, (a#0)), (a$name#0)) = A)
            +- 'GetVertices v(a, {}, (name,A), false, (a#0))

If both lower and upper bound is given, then the plan is correct. https://github.com/FTSRG/ingraph/blob/4119811a0e53ef5d6103060f19de97e25813370a/cypher-to-sql/src/test/scala/ingraph/compiler/sql/CompileSqlTest.scala#L469-L470

marci543 commented 5 years ago

The fix causes patterns with only lower bound to have an extra upper bound. MATCH (a)-[e*2..]-(b) -> Expand v(a, {}, false, (a#7)), v(b, {}, false, (b#5)), edgelistattribute(e, {}, false, (2), (2), (e#3)), Both