Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node created failed when adding path variable #4337

Closed
ljhhuxiaoba opened this issue Mar 18, 2024 · 1 comment
Closed

Node created failed when adding path variable #4337

ljhhuxiaoba opened this issue Mar 18, 2024 · 1 comment

Comments

@ljhhuxiaoba
Copy link

I execute 2 queries on my empty JanusGraph database ,and an error occurs.

JanusGraph version: 1.0.0
operating system: windows 10

first query:
g.addV().as(' UNNAMED8').addV('L').as(' UNNAMED17').property(single, 'k1', 1).addE('T').from(' UNNAMED8').to(' UNNAMED17').addV().as(' UNNAMED34').addE('T').from(' UNNAMED17').to(' UNNAMED34').barrier().limit(0)

second query:
g.addV().as(' UNNAMED10').addV('L').as(' UNNAMED19').has('k1', eq(1)).property(single, 'k1', 1).addE('T').from(' UNNAMED10').to(' UNNAMED19').addV().as(' UNNAMED36').addE('T').from(' UNNAMED19').to(' UNNAMED36').V().as(' GENERATED1').where(.select(' GENERATED1').where(eq(' UNNAMED10'))).outE('T').aggregate(' cypher.path.edge.p').inV().as(' GENERATED2').where(.select(' GENERATED2').where(eq(' UNNAMED19'))).hasLabel('L').outE('T').aggregate(' cypher.path.edge.p').inV().as(' GENERATED3').where(__.select(' GENERATED3').where(eq(' UNNAMED36'))).path().from(' GENERATED1').barrier().limit(0)

The first query creates 3 nodes but the second creates 2 nodes.
And they are translated from "CREATE ()-[:T]->(:L{k1:1})-[:T]->()" and "CREATE p=()-[:T]->(:L{k1:1})-[:T]->()" respectively. The two Cypher queries are equivalent so I think they should both create 3 nodes.

I use the plugin named cypher-for-gremlin to translate Cypher query to Gremlin query.

@FlorianHockmann
Copy link
Member

Your second query looks with proper indentation like this (I used Gremlint for this):

g.addV().as(' UNNAMED10').
  addV('L').as(' UNNAMED19').
  has('k1', eq(1)).
  property(single, 'k1', 1).
  addE('T').from(' UNNAMED10').to(' UNNAMED19').
  addV().as(' UNNAMED36').
  addE('T').from(' UNNAMED19').to(' UNNAMED36').
  V().as(' GENERATED1').
  where(select(' GENERATED1').where(eq(' UNNAMED10'))).
  outE('T').
  aggregate(' cypher.path.edge.p').
  inV().as(' GENERATED2').
  where(select(' GENERATED2').where(eq(' UNNAMED19'))).
  hasLabel('L').
  outE('T').
  aggregate(' cypher.path.edge.p').
  inV().as(' GENERATED3').
  where(__.select(' GENERATED3').where(eq(' UNNAMED36'))).
  path().from(' GENERATED1').
  barrier().
  limit(0)

and this just looks wrong to me. The 3rd line is has('k1', eq(1)) which won't result in any elements for an empty graph as no vertex has the k1 property at that point. So all following steps won't be executed any more since no traversers will reach them.

The plugin that you're using to convert Cypher queries to Gremlin also seems to be unmaintained. So, I'd advise against using it.

You can of course still use the plugin if you want to, but then please first check whether the resulting Gremlin traversal is correct before reporting issues you'll find as a bug here.
It's hard to investigate your issues if you're just posting a very long and convoluted Gremlin traversal created by such a tool. Most likely there is simply an error in the conversion from Cypher to Gremlin within the plugin and not a bug in JanusGraph.

Closing this one as the Gremlin traversal created by the Cypher plugin is syntactically wrong.

@FlorianHockmann FlorianHockmann closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants