JanusGraph / JanusGraph/janusgraph
Float property comparison fails
- Dominant language
- Java
- Stars
- 5.8k
- Forks
- 1.2k
- Avg merge
- 13h 53m
- Merged PRs (30d)
- 6
Description
Reported on [janusgraph-users thread](https://groups.google.com/d/msg/janusgraph-users/4aEjYjvzhX8/stteMYZ5CQAJ)
It is reproducible from the Gremlin Console.
```
gremlin> graph = JanusGraphFactory.open('inmemory')
==>standardjanusgraph[inmemory:[127.0.0.1]]
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@2938127d
gremlin> float_prop = mgmt.makePropertyKey('float_prop').dataType(Float.class).cardinality(Cardinality.LIST).make()
==>float_prop
gremlin> mgmt.commit()
==>null
gremlin> g = graph.traversal()
==>graphtraversalsource[standardjanusgraph[inmemory:[127.0.0.1]], standard]
gremlin> v = g.addV().property(VertexProperty.Cardinality.list, 'float_prop', 1.1f).next()
==>v[4176]
gremlin> g.V(v).has('float_prop', 1.1).toList()
==>v[4176]
gremlin> g.V(v).properties('float_prop').hasValue(1.1).toList()
Property value [1.1] is of type class java.math.BigDecimal is not supported
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.IllegalArgumentException: Property value [1.1] is of type class java.math.BigDecimal is not supported
at org.apache.tinkerpop.gremlin.structure.Property$Exceptions.dataTypeOfPropertyValueNotSupported(Property.java:163)
at org.apache.tinkerpop.gremlin.structure.Property$Exceptions.dataTypeOfPropertyValueNotSupported(Property.java:159)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.verifyAttribute(StandardJanusGraphTx.java:578)
at org.janusgraph.graphdb.query.QueryUtil.addConstraint(QueryUtil.java:206)
at org.janusgraph.graphdb.query.QueryUtil.constraints2QNF(QueryUtil.java:196)
at org.janusgraph.graphdb.query.vertex.BasicVertexCentricQueryBuilder.constructQueryWithoutProfile(BasicVertexCentricQueryBuilder.java:422)
at org.janusgraph.graphdb.query.vertex.BasicVertexCentricQueryBuilder.constructQuery(BasicVertexCentricQueryBuilder.java:399)
at org.janusgraph.graphdb.query.vertex.VertexCentricQueryBuilder.execute(VertexCentricQueryBuilder.java:68)
at org.janusgraph.graphdb.query.vertex.VertexCentricQueryBuilder.properties(VertexCentricQueryBuilder.java:100)
at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphPropertiesStep.flatMap(JanusGraphPropertiesStep.java:117)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:49)
at org.janusgraph.graphdb.tinkerpop.optimize.JanusGraphPropertiesStep.processNextStart(JanusGraphPropertiesStep.java:107)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:128)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.next(AbstractStep.java:38)
at org.apache.tinkerpop.gremlin.process.traversal.Traversal.fill(Traversal.java:177)
at org.apache.tinkerpop.gremlin.process.traversal.Traversal.toList(Traversal.java:115)
at org.apache.tinkerpop.gremlin.process.traversal.Traversal$toList$0.call(Unknown Source)
```
Unlike the `HasStep`, the `JanusGraphPropertiesStep` doesn't appear to handle `Float` vs `Double` vs `BigDecimal` comparison gracefully -- Final Traversal `[GraphStep(vertex,[v[4176]]), JanusGraphPropertiesStep([~value.eq(1.1)])]`
Contributor guide
Research direction
Start with JanusGraphPropertiesStep and its properties query path, then compare it with the HasStep behavior described in the issue. Trace QueryUtil.addConstraint into StandardJanusGraphTx.verifyAttribute to see how Float, Double, and BigDecimal values are validated. Done means the reproducible Gremlin traversal handles the comparison without the reported unsupported-type exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100