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

Unsupported Cypher Map Projections expression with translation library #360

Open ankit-joinwal opened 3 years ago

ankit-joinwal commented 3 years ago

Here is the Pom file:

 <dependency>
      <groupId>org.opencypher.gremlin</groupId>
      <artifactId>translation</artifactId>
      <version>1.0.4</version>
  </dependency>

Source code:

import org.opencypher.gremlin.translation.CypherAst
import org.opencypher.gremlin.translation.translator.Translator
import org.opencypher.gremlin.translation.translator.TranslatorFlavor

fun main() {

        val cypher = """
      MATCH (decks:Deck)
        WHERE decks.externalId = 'abcd'
        RETURN decks {
            .tokenizedName
        } AS decks
        """
        val ast = CypherAst.parse(cypher)
    val translator = Translator.builder()
        .gremlinGroovy()
        .inlineParameters()
        .enableMultipleLabels()
        .build(TranslatorFlavor.neptune())
        val gremlin = ast.buildTranslation(translator)
        System.out.println(gremlin)
    }

Produces following exception :

Exception in thread "main" java.lang.UnsupportedOperationException: Unsupported value expression: DesugaredMapProjection(Variable(decks),List(LiteralEntry(PropertyKeyName(tokenizedName),Property(Variable(decks),PropertyKeyName(tokenizedName)))),false)
    at org.opencypher.gremlin.translation.context.WalkerContext.unsupported(WalkerContext.scala:69)
    at org.opencypher.gremlin.translation.walker.NodeUtils$.traversalValueToJava(NodeUtils.scala:51)
    at org.opencypher.gremlin.translation.walker.NodeUtils$.expressionValue(NodeUtils.scala:35)
    at org.opencypher.gremlin.translation.walker.ExpressionWalker.org$opencypher$gremlin$translation$walker$ExpressionWalker$$walkLocal(ExpressionWalker.scala:326)
    at org.opencypher.gremlin.translation.walker.ExpressionWalker$.walkLocal(ExpressionWalker.scala:49)
    at org.opencypher.gremlin.translation.walker.ProjectionWalker.walkLocal(ProjectionWalker.scala:411)
    at org.opencypher.gremlin.translation.walker.ProjectionWalker.subTraversal(ProjectionWalker.scala:279)
    at org.opencypher.gremlin.translation.walker.ProjectionWalker.$anonfun$returnSubTraversals$1(ProjectionWalker.scala:119)
    at scala.collection.Iterator.foreach(Iterator.scala:937)
    at scala.collection.Iterator.foreach$(Iterator.scala:937)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
    at scala.collection.IterableLike.foreach(IterableLike.scala:70)
    at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
    at org.opencypher.gremlin.translation.walker.ProjectionWalker.returnSubTraversals(ProjectionWalker.scala:116)
    at org.opencypher.gremlin.translation.walker.ProjectionWalker.walk(ProjectionWalker.scala:75)
    at org.opencypher.gremlin.translation.walker.ProjectionWalker.walkFinal(ProjectionWalker.scala:101)
    at org.opencypher.gremlin.translation.walker.ProjectionWalker$.walk(ProjectionWalker.scala:44)
    at org.opencypher.gremlin.translation.walker.StatementWalker.walkClause(StatementWalker.scala:125)
    at org.opencypher.gremlin.translation.walker.StatementWalker.$anonfun$walkSingle$1(StatementWalker.scala:84)
    at org.opencypher.gremlin.translation.walker.StatementWalker.$anonfun$walkSingle$1$adapted(StatementWalker.scala:84)
    at scala.collection.immutable.List.foreach(List.scala:388)
    at org.opencypher.gremlin.translation.walker.StatementWalker.walkSingle(StatementWalker.scala:84)
    at org.opencypher.gremlin.translation.walker.StatementWalker.walk(StatementWalker.scala:45)
    at org.opencypher.gremlin.translation.walker.StatementWalker$.walk(StatementWalker.scala:32)
    at org.opencypher.gremlin.translation.CypherAst.translate(CypherAst.scala:98)
    at org.opencypher.gremlin.translation.CypherAst.buildTranslation(CypherAst.scala:119)
    at org.neo4j.graphql.examples.dgsspringboot.datafetcher.CypherToGremlinKt.main(CypherToGremlin.kt:24)
    at org.neo4j.graphql.examples.dgsspringboot.datafetcher.CypherToGremlinKt.main(CypherToGremlin.kt)

Am i missing something here? Please help.

ankit-joinwal commented 3 years ago

Are Cypher Map Projections supported ? https://neo4j.com/docs/cypher-manual/current/syntax/maps/#cypher-map-projection-examples. This seems related to map projections as used in the example cypher query

lvca commented 2 years ago

Any news on this? @ankit-joinwal were you able to find a workaround?