[Bug] Wrong result for where(count().is(lt(0))) when counted traversal is empty

Open
#3,084 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java
Domain
backend, databases

Research direction

Start by reproducing the minimal graph and query g.V('a').where(__.both('R').count().is(lt(0))).values('i') against the stated HugeGraph 1.7.0 environment. Trace the where() child traversal behavior for an empty both('R') result and add coverage for this case; done means the query returns [] rather than `[1]].

Written by the indexing model from the issue text.

Description

bug gremlin
Bug Type (问题类型)

gremlin (结果不合预期)

Before submit
  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
Environment (环境信息)
  • Server Version: 1.7.0
  • gremlin: 3.5.1
  • Docker Image: hugegraph/hugegraph:latest
  • Backend: default Docker standalone backend
  • Data Size: 1 vertex, 0 edges
Expected & Actual behavior (期望与实际表现)

HugeGraph keeps a traverser for a where() child traversal whose count() is 0 and whose predicate is lt(0).

Minimal graph:
(a:A {i: 1})

No R edges exist.

Bug-triggering query:
g.V('a').where(__.both('R').count().is(lt(0))).values('i')

Expected:
[]

Actual:
[1]

Since the counted traversal returns 0, the predicate lt(0) should be false.

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



curl -fsS --compressed -X DELETE \
  "http://127.0.0.1:8080/graphs/hugegraph/clear?confirm_message=I'm%20sure%20to%20delete%20all%20data"

curl -fsS --compressed -H 'Content-Type: application/json' -X POST \
  -d '{"id":"a","label":"A","properties":{"i":1}}' \
  "http://127.0.0.1:8080/graphs/hugegraph/graph/vertices"
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
**Schema**



curl -fsS --compressed -H 'Content-Type: application/json' -X POST \
  -d '{"name":"i","data_type":"LONG","cardinality":"SINGLE"}' \
  "http://127.0.0.1:8080/graphs/hugegraph/schema/propertykeys"

curl -fsS --compressed -H 'Content-Type: application/json' -X POST \
  -d '{"name":"A","id_strategy":"CUSTOMIZE_STRING","properties":["i"],"nullable_keys":["i"],"enable_label_index":true}' \
  "http://127.0.0.1:8080/graphs/hugegraph/schema/vertexlabels"

curl -fsS --compressed -H 'Content-Type: application/json' -X POST \
  -d '{"name":"B","id_strategy":"CUSTOMIZE_STRING","properties":[],"nullable_keys":[],"enable_label_index":true}' \
  "http://127.0.0.1:8080/graphs/hugegraph/schema/vertexlabels"

curl -fsS --compressed -H 'Content-Type: application/json' -X POST \
  -d '{"name":"R","source_label":"B","target_label":"A","frequency":"SINGLE","properties":[],"nullable_keys":[],"enable_label_index":true}' \
  "http://127.0.0.1:8080/graphs/hugegraph/schema/edgelabels"
Dominant language
Java
Stars
3.2k
Forks
637
Avg merge
3d 18h
Merged PRs (30d)
23

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/hugegraph

All issues in apache/hugegraph

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.