apache / incubator-hugegraph

A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
https://hugegraph.apache.org
Apache License 2.0
2.66k stars 520 forks source link

Outside() API can not process boolean value #1595

Open Yicheng-Wang opened 3 years ago

Yicheng-Wang commented 3 years ago

Bug Type (问题类型)

gremlin (结果不合预期)

Before submit

Environment (环境信息)

Expected & Actual behavior (期望与实际表现)

Expected behavior

We executed the query “ g.V().has('person', 'married', outside(true, true))”, and expected to get the vertices whose property ‘married’ was FALSE.

Actual behavior

An exception was thrown:

java.lang.NumberFormatException: Error encountered evaluating script: g.V().has('person', 'married', outside(true, true))
    at com.baidu.hugegraph.exception.ServerException.fromResponse(ServerException.java:47)
    at com.baidu.hugegraph.client.RestClient.checkStatus(RestClient.java:93)
    at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:198)
    at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:172)
    at com.baidu.hugegraph.api.gremlin.GremlinAPI.post(GremlinAPI.java:41)
    at com.baidu.hugegraph.driver.GremlinManager.execute(GremlinManager.java:51)
    at com.baidu.hugegraph.api.gremlin.GremlinRequest$Builder.execute(GremlinRequest.java:55)
    at org.gdbtesting.hugegraph.HugeGraphConnection.main(HugeGraphConnection.java:296)
Caused by: [java.lang.NumberFormatException]

Example to reproduce

        hugegraph.schema().propertyKey("married").asBoolean().ifNotExist().create();

        hugegraph.schema().vertexLabel("person").properties("married").nullableKeys("married").create();
        hugegraph.schema().indexLabel("personbymarried").onV("person").by("married").shard().ifNotExist().create();

        GraphManager graph = hugegraph.graph();

        Vertex person1 = new Vertex("person").property("married", true);
        Vertex person2 = new Vertex("person").property("married", false);
        Vertex person3 = new Vertex("person").property("married", false);
        Vertex person4 = new Vertex("person").property("married", false);

        graph.addVertices(Arrays.asList(person1, person2, person3, person4));

        GremlinManager gremlin = hugegraph.gremlin();

        String query0 = "g.V().has('person', 'married', outside(true, true))";
        System.out.println("query0 : " + query0);
        try{
            ResultSet hugeResult = gremlin.gremlin(query0).execute();
            Iterator<Result> huresult = hugeResult.iterator();
            huresult.forEachRemaining(result -> {
                Object object = result.getObject();
                System.out.println(object);
            });
        }catch(Exception e){
            e.printStackTrace();
        }

The code and query of same logic will not cause exception in other gremlin-based graph databases.

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

Yicheng-Wang commented 3 years ago

@imbajin Could you please check whether this bug is related to HugeGraph? Thanks a lot~

imbajin commented 3 years ago

I'm not sure, assign other devs to check ⏲️

javeme commented 3 years ago

@Yicheng-Wang The outside() syntax only supports numeric properties, within() or without() syntax supports boolean properties.