JanusGraph / JanusGraph/janusgraph

Incorrect OR evaluation in JanusGraphStep

Open
#4,786 0 comments 0 reactions 0 assignees View on GitHub
kind/bug/possible
Dominant language
Java
Stars
5.8k
Forks
1.2k
Avg merge
13h 53m
Merged PRs (30d)
6

Description

There's a noticeable difference in the evaluation of `or()` conditions together with vertex id. Depending on whether the initial vertex lookup is done with `g.V().has(T.id, ...)` or `g.V(...)`. When using
```
g.V().has(T.id, 1).or(__.has("prop", "A", __.has("prop", "B")))
```
the query optimizer (`JanusGraphStepStrategy`) folds all conditions into a `JanusGraphStep`. This seems to lead to an incorrect evaluation where the `or()` behaves like an `and()` - in `JanusGraphStep` all conditions are evaluated using `HasContainer.testAll()` method.

However, the query
```
g.V(1).or(__.has("prop", "A", __.has("prop", "B")))
```
produces the correct OR results, because folding is skipped in `JanusGraphStepStrategy`.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the two queries and tracing the folding behavior in JanusGraphStepStrategy, then inspect JanusGraphStep and HasContainer.testAll(). Done means the g.V().has(T.id, ...) form preserves OR semantics like the g.V(...) form, without changing the correct behavior of the latter.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.