Equivalent queries create a different number of nodes
ljhhuxiaoba opened this issue · 1 comments
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.inject(' cypher.start').choose(.V().as('n0').inE().outV().as('n1'), .V().as('n0').inE().outV().as('n1'), .constant(' cypher.null').as('n0').as('n1')).select('n0', 'n1').project('n0', 'n1').by(.select('n0')).by(.select('n1')).as(' GENERATED2').select('n0').as('n0').select(' GENERATED2').select('n1').as('n1').addV().project('a0').by(.constant(1))
second query:
g.inject(' cypher.start').choose(.V().as('n0').V().inE().as('m0').outV().V().as('n1').where(.select('n0').is(neq(' cypher.null')).inE().as(' GENERATED3').where(.select(' GENERATED3').where(eq('m0'))).outV().as(' GENERATED5').where(.select(' GENERATED5').where(eq('n1'))).choose(.is(neq(' cypher.null')), .constant(true), .constant(false)).is(neq(' cypher.null')).is(eq(true))), .V().as('n0').V().inE().as('m0').outV().V().as('n1').where(.select('n0').is(neq(' cypher.null')).inE().as(' GENERATED3').where(.select(' GENERATED3').where(eq('m0'))).outV().as(' GENERATED5').where(.select(' GENERATED5').where(eq('n1'))).choose(.is(neq(' cypher.null')), .constant(true), .constant(false)).is(neq(' cypher.null')).is(eq(true))), .constant(' cypher.null').as('n0')).select('m0', 'n0', 'n1').project('m0', 'n0', 'n1').by(.select('m0')).by(.select('n0')).by(.select('n1')).as(' GENERATED6').select('m0').as('m0').select(' GENERATED6').select('n0').as('n0').select(' GENERATED6').select('n1').as('n1').addV().project('a0').by(__.constant(1))
The first query creates 1 node but the second creates 0 node.
And they are translated from "OPTIONAL MATCH (n0)<-[]-(n1) WITH * CREATE (n2) RETURN 1 AS a0" and "OPTIONAL MATCH (n0),()<-[m0]-(),(n1) WHERE exists((n0)<-[m0]-(n1)) WITH * CREATE (n2) RETURN 1 AS a0" respectively. The two Cypher queries are equivalent so I think they should both create a node.
I use the plugin named cypher-for-gremlin to translate Cypher query to Gremlin query.
Closed as this is most likely not an issue with JanusGraph, but with cypher-for-gremlin. See my comment in a different similar issue for more information.