inject/where/choose combination causes ClassCastException
See original GitHub issueThe following query causes a ClassCastException:
g.inject('test').
where(
choose(
__.V().hasLabel('DoesntMatter'),
__.constant(true),
__.constant(false)
)
)
Note that while this gremlin is a little nonsensical, it represents a reduction of a much more complicated gremlin which also fails.
The exception trace is:
gremlin> g.inject('test').
......1> where(
......2> choose(
......3> __.V().hasLabel('DoesntMatter'),
......4> __.constant(true),
......5> __.constant(false)
......6> )
......7> )
class java.lang.String cannot be cast to class org.umlg.sqlg.structure.SqlgElement (java.lang.String is in module java.base of loader 'bootstrap'; org.umlg.sqlg.structure.SqlgElement is in unnamed module of loader 'app')
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.ClassCastException: class java.lang.String cannot be cast to class org.umlg.sqlg.structure.SqlgElement (java.lang.String is in module java.base of loader 'bootstrap'; org.umlg.sqlg.structure.SqlgElement is in unnamed module of loader 'app')
at org.umlg.sqlg.step.barrier.SqlgBranchStepBarrier.processNextStart(SqlgBranchStepBarrier.java:80)
at org.umlg.sqlg.step.SqlgAbstractStep.hasNext(SqlgAbstractStep.java:121)
at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:196)
at org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil.test(TraversalUtil.java:96)
at org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep.filter(TraversalFilterStep.java:59)
at org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep.processNextStart(FilterStep.java:38)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:144)
at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:196)
at java_util_Iterator$hasNext.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at org.apache.tinkerpop.gremlin.console.Console$_closure3.doCall(Console.groovy:257)
FWIW, this seems to work around the problem:
g.V().limit(1).constant("test")
where(
choose(
__.V().hasLabel('DoesntMatter'),
__.constant(true),
__.constant(false)
)
)
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Explanation of ClassCastException in Java
The reason an exception is thrown here is that when I'm creating my list object, the object I store in the list is...
Read more >Handling the ClassCastException Runtime Exception in Java
The ClassCastException in Java happens when the JVM tries to cast an object to a class (or in some instances, an interface) and...
Read more >ClassCastException thrown by combination of ktlint and ...
ClassCastException is thrown by combination of ktlint and Dokka. The exception message is as follows: java.lang.ClassCastException: org.
Read more >ClassCastException (Java Platform SE 7 )
Class ClassCastException Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an...
Read more >Solved: ClassCastException When Instantiating Script Inclu...
ClassCastException When Instantiating Script Include in Transform Map Script ... tried both of the below in combo with the various code attempts below...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@allenhadden can you please test your more complex query? I added a bunch of
InjectStep
optimizations.Some feedback, I have made progress, at least the trimmed down test you provided, thanks for that, passes. Your usecase bypasses Sqlg’s bypassing of
inject
. Sqlg does not optimize traversals that containInjectStep
. However your gremlin’s nested traversals did not quite realize the input came via aninject
and attempted to optimize it…