Details
Description
The query below (a) in bytecode format represents the query "g.V().hasLabel('Person').has('Age), gt(30))" and contains a binding as an argument to P.gt. When sent over Websocket to Gremlin Serve 3.4.4, it leads to the exception (b) on the server.
Furthermore, running the following query in Gremlin Console 3.4.4 suggests that bindings are not serialized to bytecode if in a predicate:
gremlin> g.V().has(b.of('z','person'),b.of('y','age'),P.gt(b.of('x',30))).getBytecode() ==>[[], [V(), has(binding[z=person], binding[y=age], gt(30))]]
There's a corresponding discussion in gremlin-users: https://groups.google.com/forum/#!topic/gremlin-users/ltVdaxSQY1s
There also has been a previous issue dealing with gremlinpython that was closed as "not a problem": https://issues.apache.org/jira/browse/TINKERPOP-1887
(a)
{ "requestId": "c210d51a-42de-4906-b4c7-8af5d21d6024", "op": "bytecode", "processor": "traversal", "args": { "gremlin": { "@type": "g:Bytecode", "@value": { "step": [ [ "V" ], [ "hasLabel", { "@type": "g:Binding", "@value": { "value": "Person", "key": "_a" } } ], [ "has", { "@type": "g:Binding", "@value": { "value": "Age", "key": "_b" } }, { "@type": "g:P", "@value": { "predicate": "gt", "value": { "@type": "g:Binding", "@value": { "value": { "@type": "g:Int32", "@value": 30 }, "key": "_c" } } } } ] ] } }, "aliases": { "g": "g" } } }
(b)
java.lang.IllegalArgumentException: Cannot compare '29' (Integer) and 'binding[_c=30]' (Binding) as both need to be an instance of Number or Comparable (and of the same type) at org.apache.tinkerpop.gremlin.process.traversal.Compare.throwException(Compare.java:193) at org.apache.tinkerpop.gremlin.process.traversal.Compare.access$300(Compare.java:34) at org.apache.tinkerpop.gremlin.process.traversal.Compare$3.test(Compare.java:96) at org.apache.tinkerpop.gremlin.process.traversal.P.test(P.java:72) at org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer.testValue(HasContainer.java:118) at org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer.test(HasContainer.java:94) at org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer.testAll(HasContainer.java:180) at org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.step.sideEffect.TinkerGraphStep.iteratorList(TinkerGraphStep.java:133) at org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.step.sideEffect.TinkerGraphStep.vertices(TinkerGraphStep.java:101) at org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.step.sideEffect.TinkerGraphStep.lambda$new$0(TinkerGraphStep.java:65) at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:157) at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143) at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:50) at org.apache.tinkerpop.gremlin.process.traversal.step.map.MapStep.processNextStart(MapStep.java:36) at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:143) at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:197) at org.apache.tinkerpop.gremlin.server.util.TraverserIterator.fillBulker(TraverserIterator.java:69) at org.apache.tinkerpop.gremlin.server.util.TraverserIterator.hasNext(TraverserIterator.java:56) at org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.handleIterator(TraversalOpProcessor.java:512) at org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.lambda$iterateBytecodeTraversal$4(TraversalOpProcessor.java:411) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)