Janusgraph: Gremlin is unable to search non-string properties when searched as a String after using in/out operation on a vertex

Created on 24 Feb 2021  路  3Comments  路  Source: JanusGraph/janusgraph

  • Version: 0.5.3
  • Storage Backend: cql, in-memory
  • Expected Behavior: Gremlin should automatically convert the String argument to the corresponding datatype for the property as it is doing for simple queries when not traversing in and out of a vertex
  • Current Behavior: Gremlin does not convert String argument to its equivalent non-String datatype

  • Steps to Reproduce:

  1. start gremlin.bat in windows

  2. Execute below commands to load GraphOfTheGods

gremlin> graph = JanusGraphFactory.open('conf/janusgraph-inmemory.properties')
gremlin> GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true)
gremlin> g = graph.traversal()

  1. Test the query.
    gremlin> g.V().has('age','4500').valueMap()
    ==>[name:[neptune],age:[4500]]

  2. Test the below query.
    gremlin> g.V().has('name','neptune').out().in().has('age','4500').valueMap()
    Result is Empty

  3. Test the same query, now instead using String for age use the actual datatype
    gremlin> g.V().has('name','neptune').out().in().has('age',4500).valueMap()
    ==>[name:[neptune],age:[4500]]
    ==>[name:[neptune],age:[4500]]
    ==>[name:[neptune],age:[4500]]

The issue exists in all the versions of gremlin.
The issue can also be reproduced with other datatypes such UUID, date etc.

I also changed the example-common program(PSA) to check if the issue is in gremlin console or the gremlin API.
In the example program I tested with adding UUID and date fields in schema, the issue got reproduced for those datatypes as well in the java program.

example-common.zip

Stack Trace (if you have one)

paste stack trace here
kinbupossible

Most helpful comment

Didn't know that JanusGraph converts string arguments to the expected data type like. I think though that we should not also add this behavior for later parts of the traversal, but instead completely stop doing it as it's unexpected behavior in my opinion. If you define an age property with a data type int then it shouldn't work when you provide a string argument.
So, I agree with @rngcntr that the first step here isn't behaving as expected and should therefore be changed.

All 3 comments

Hi @pratikjain1991, thanks for reporting!

I tested the same scenario with TinkerGraph to find out if this is actually JanusGraph or TinkerPop related. In the case of TinkerGraph, string literals are never accepted as integer values so even step 3 in your explanation returns an empty result.
This makes me think that the difference lies in the implementation of JanusGraphStep. This step provides an entry point to the traversal and is handled specially. That means the first step is actually what operates out of specification by accepting string literals.

Didn't know that JanusGraph converts string arguments to the expected data type like. I think though that we should not also add this behavior for later parts of the traversal, but instead completely stop doing it as it's unexpected behavior in my opinion. If you define an age property with a data type int then it shouldn't work when you provide a string argument.
So, I agree with @rngcntr that the first step here isn't behaving as expected and should therefore be changed.

I Upvote this issue if there's such a thing here.

Was this page helpful?
0 / 5 - 0 ratings