Repository navigation
Closed
Description
ArcadeDB version
26.8.1-SNAPSHOT, main at 74f776d (i.e. with #5460, #5480 and #5481 merged).
Environment
- Query language: Cypher (OpenCypher engine)
- Reproduced from an engine unit test against an embedded database
Description
A relationship inline WHERE predicate on a variable-length pattern is discarded outright. The
predicate has no effect on the result at all: WHERE false and WHERE true return the same rows.
The fixed-length spelling of the same predicate works correctly (fixed by #5460), and the
variable-length property map spelling works correctly, so the gap is specific to the inline
WHERE slot on variable-length patterns.
Because the predicate is silently ignored rather than rejected, queries return too many rows
with no error.
Steps to reproduce
CREATE (a:A {v:1}), (b:A {v:10}), (c:A {v:2});
MATCH (a:A {v:1}), (b:A {v:10}), (c:A {v:2})
CREATE (a)-[:E {tag:'ok', w:5}]->(b), (a)-[:E {tag:'bad', w:99}]->(c);Only one of the two edges has tag = 'ok', so the expected count is 1.
-- correct (fixed length)
MATCH (a:A {v:1})-[r:E WHERE r.tag = 'ok']->(x:A) RETURN count(r) AS c;
-- c = 1
-- BUG: variable length, predicate ignored
MATCH (a:A {v:1})-[r:E*1..1 WHERE r.tag = 'ok']->(x:A) RETURN count(*) AS c;
-- c = 2
-- expected: c = 1Proof that the predicate is dropped, not mis-evaluated
| Query fragment | Result | Expected | Verdict |
|---|---|---|---|
-[r:E*1..1 WHERE r.tag = 'ok']-> |
2 |
1 |
BUG |
-[r:E*1..2 WHERE r.tag = 'ok']-> |
2 |
1 |
BUG |
-[r:E*1..1 WHERE false]-> |
2 |
0 |
BUG (conclusive) |
-[r:E*1..1 WHERE true]-> |
2 |
2 |
OK |
-[r:E*1..1 {tag:'ok'}]-> (property map) |
1 |
1 |
OK |
-[r:E*1..1]-> + clause WHERE all(e IN r WHERE e.tag = 'ok') |
1 |
1 |
OK |
WHERE false returning 2 rows is conclusive: the predicate never reaches the traversal.
Notes
- Semantics to settle when fixing: for
*min..maxthe predicate should almost certainly apply
per-hop (every traversed edge must satisfy it), matching Neo4j, rather than to the edge list as a
whole. Theall(e IN r WHERE ...)clause-level form above is the equivalent that already works. - Verified and documented as a known gap during PR fix(#5463, #5462): pin count(*) against a relationship inline WHERE predicate #5485 but never given its own ticket.
- Distinct from Cypher: variable-length path follow-ups to PR #5357 (VarLengthExpand physical operator, anchor-guard relaxations) #5358, which concerns optimizer anchor selection for variable-length paths, not
predicate correctness.
Activity
fix(#5490): apply the relationship inline WHERE on variable-length pa…
fix(#5490): apply the relationship inline WHERE on variable-length pa…