[ 
https://issues.apache.org/jira/browse/TINKERPOP-2909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17701132#comment-17701132
 ] 

Stephen Mallette commented on TINKERPOP-2909:
---------------------------------------------

I suppose it's syntactically correct but at runtime it's going to have a 
problem. You're doing {{where(within('x'))}} where "x" references a single 
{{Vertex}}. {{within()}} in this context is expecting a {{Collection}} so you 
get that error. Depending on the context of what you are querying you either 
need to give it a {{Collection}}:

{code}
g.V().in('el1').fold().as('x').
  V().both('el0','el1').inE('el1').outV().where(within('x'))
{code}

or change the {{P}}:

{code}
g.V().in('el1').as('x').
  V().both('el0','el1').inE('el1').outV().where(eq('x'))
{code}

> Throw ClassCastException
> ------------------------
>
>                 Key: TINKERPOP-2909
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2909
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: driver, server
>    Affects Versions: 3.6.2
>         Environment: - TinkerGraph Version: 3.6.2
> - Operating system: macOS 13.2.1
> - API/Driver: Java
>            Reporter: Zeyang Zhuang
>            Priority: Major
>
> I first randomly create a graph. Then when I run the following query: 
> `g.V().in('el1').as('x').V().both('el0','el1').inE('el1').outV().where(within('x'))`
>  is thrown with an exception. I think this query is syntactically correct, 
> but I keep triggering this kind of problem. I generate the query based on the 
> rule which can be refered from: 
> [https://stackoverflow.com/questions/48067834/gremlin-intersection-operation].
>  Following this instruction, I think it's allowed to generate this kind of 
> queries.
> *Expected behavior:*
> No exception should be expected to throw. Or futher messages or prompts 
> should be thrown.
> *Actual behavior:*
> A `java.util.concurrent.ExecutionException` is thrown. And I'm not really 
> sure whether this problem should happen so I report this.
> ```
> java.util.concurrent.ExecutionException: 
> org.apache.tinkerpop.gremlin.driver.exception.ResponseException: 
> org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex cannot be 
> cast to java.util.Collection
> ```



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to