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

Resolution error for graph elements as lists items #332

Open szarnyasg opened 6 years ago

szarnyasg commented 6 years ago

The following query does not compile because the compiler does not expect that a list item can be a graph element (in this case, a vertex).

MATCH (p:Person)
WITH collect(p) AS ps
WITH ps[0] AS p
RETURN p.id

Stacktrace:

Unexpected type found: class ingraph.model.expr.ExpressionAttribute at basis position of property dereferencing. String value of the object is: expressionattribute(indexlookupexpression(expressionattribute('collect(vertexattribute(p, vertexlabelset(Empty), false, Some(p#0))), ps, Some(ps#0)), 0), p, Some(p#1))
ingraph.compiler.exceptions.UnexpectedTypeException: Unexpected type found: class ingraph.model.expr.ExpressionAttribute at basis position of property dereferencing. String value of the object is: expressionattribute(indexlookupexpression(expressionattribute('collect(vertexattribute(p, vertexlabelset(Empty), false, Some(p#0))), ps, Some(ps#0)), 0), p, Some(p#1))
    at ingraph.compiler.cypher2qplan.QPlanResolver$$anonfun$expressionNameResolver$1.applyOrElse(QPlanResolver.scala:246)
    at ingraph.compiler.cypher2qplan.QPlanResolver$$anonfun$expressionNameResolver$1.applyOrElse(QPlanResolver.scala:194)
    at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$2.apply(TreeNode.scala:267)
    at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$2.apply(TreeNode.scala:267)
    at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:70)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:266)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transform(TreeNode.scala:256)
    at ingraph.compiler.cypher2qplan.QPlanResolver$.ingraph$compiler$cypher2qplan$QPlanResolver$$r2$1(QPlanResolver.scala:105)
    at ingraph.compiler.cypher2qplan.QPlanResolver$.ingraph$compiler$cypher2qplan$QPlanResolver$$r$1(QPlanResolver.scala:103)
    at ingraph.compiler.cypher2qplan.QPlanResolver$$anonfun$4.apply(QPlanResolver.scala:137)
    at ingraph.compiler.cypher2qplan.QPlanResolver$$anonfun$4.apply(QPlanResolver.scala:136)

This is not a serious issue, as it can be trivially worked around by collecting the ids in the first place:

MATCH (p:Person)
WITH collect(p.id) AS ps
WITH ps[0] AS p
RETURN p

So we should only work on this if it's not a significant effort.