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

Prettifier does not support UNION clause #5

Closed
mad opened this issue Nov 6, 2019 · 2 comments
Closed

Prettifier does not support UNION clause #5

mad opened this issue Nov 6, 2019 · 2 comments

Comments

@mad
Copy link

mad commented Nov 6, 2019

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)
  }
@bob-bierman-maritz
Copy link

bob-bierman-maritz commented Feb 25, 2020

I have the same issue...

MATCH (p:Person) WHERE p.paxId < 175
UNION
MATCH (p:Person) WHERE p.paxId >= 175
RETURN p.controlNum

scala.MatchError: Query(None,UnionDistinct(SingleQuery(List(Match(false,Pattern(List(EveryPath(NodePattern(Some(Variable(p)),Stream(LabelName(Person), ?),None,None)))),List(),Some(Where(LessThan(Property(Variable(p),PropertyKeyName(paxId)),SignedDecimalIntegerLiteral(175))))))),SingleQuery(List(Match(false,Pattern(List(EveryPath(NodePattern(Some(Variable(p)),List(LabelName(Person)),None,None)))),List(),Some(Where(GreaterThanOrEqual(Property(Variable(p),PropertyKeyName(paxId)),SignedDecimalIntegerLiteral(175))))), Return(false,ReturnItems(false,List(UnaliasedReturnItem(Property(Variable(p),PropertyKeyName(controlNum)),p.controlNum))),None,None,None,Set()))))) (of class org.opencypher.v9_0.ast.Query)

at org.opencypher.v9_0.ast.prettifier.Prettifier.asString(Prettifier.scala:22)
at org.neo4j.ogm.label.LabelProvider.addLabel(LabelProvider.java:115)

[]https://github.com/meistermeier/neo4j-ogm-label-extension/blob/master/src/main/java/org/neo4j/ogm/label/LabelProvider.java

My workaround is ugly, so any help is appreciated.

@sherfert
Copy link
Collaborator

This should have been fixed. (Actually a long time ago, apologies for only replying now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants