opencypher / cypher-for-gremlin

Cypher for Gremlin adds Cypher support to any Gremlin graph database.
Apache License 2.0
359 stars 48 forks source link

Prettifier does not support UNION clause #330

Closed mad closed 5 years ago

mad commented 5 years ago

Any query with union clause can't be prettified

MATCH (n:Actor)
RETURN n.name AS name
UNION ALL MATCH (n:Movie)
RETURN n.title AS name
scala.MatchError: Query(None,UnionDistinct(SingleQuery(List(Match(... (of class org.opencypher.v9_0.ast.Query)

    at org.opencypher.v9_0.ast.prettifier.Prettifier.asString(Prettifier.scala:22)

Possible solutions

case class Prettifier(mkStringOf: ExpressionStringifier) {
  def asString(statement: Statement): String = statement match {
    case Query(_, SingleQuery(clauses)) =>
      clauses.map(dispatch).mkString(NL)
    case Query(_, union : UnionDistinct) =>
      union.unionedQueries.map(q => q.clauses.map(dispatch).mkString(NL)).mkString(NL + "UNION" + NL)
    case Query(_, union : UnionAll) =>
      union.unionedQueries.map(q => q.clauses.map(dispatch).mkString(NL)).mkString(NL + "UNION ALL" + NL)
  }
dwitry commented 5 years ago

Hello @mad,

could you please elaborate more on this issue. Provided query appears to be ok in Cypher for Gremlin. Is this for front-end?

mad commented 5 years ago

Oh sorry, Prettifier is not part of cypher-for-gremlin project https://github.com/opencypher/front-end/issues/5