Search code examples
gremlinamazon-neptune

step.map.PropertyMapStep cannot be cast to step.ByModulating


I am trying to run the following query against the AWS Neptune.

g.V(1).project('id', 'type', 'properties') \
      .by(id) \
      .by(label) \
      .by(valueMap().by(unfold()))

Calling it via HTTP request raises the following error

{
    "requestId": "5eb536e9-017a-db82-9234-db5c556e386f",
    "code": "MalformedQueryException",
    "detailedMessage": "Failed to interpret Gremlin query: org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertyMapStep cannot be cast to org.apache.tinkerpop.gremlin.process.traversal.step.ByModulating"
}

Using the gremlin-python client

gremlin_python.driver.protocol.GremlinServerError: 599: {"requestId":"11f7c020-f2d5-445a-b35a-ee531c31a7e3","code":"InternalFailureException","detailedMessage":"null:by([[UnfoldStep]])"}

How the query should look like? I am exhausted of finding out ways to modify the queries in order to be interpreted by Neptune.

Note that the query executes successfully in Gremlin console!


Solution

  • Found that the above query could be rewritten as

    g.V(1).project('id', 'type', 'properties') \
          .by(id) \
          .by(label) \
          .by(properties().group().by(__.key()).by(__.value()))
    

    However I am still confused why the original query does not work. It would be nice, if someone could explain that to me.