ArcadeDB version
Observed on latest Docker image:
docker pull arcadedata/arcadedb:latest
Pulled: 2026-07-08
Digest: sha256:77545aac242ce2bf202cd6e85d2a4be1eb816b8fd25af999b8e4155009bc1582
ArcadeDB version: 26.7.2-SNAPSHOT
Build: f88429c1
Endpoint:
http://127.0.0.1:2480/api/v1/command/test
Environment
-
Host OS: Linux 5.4.0-216-generic
-
Deployment: Docker arcadedata/arcadedb:latest
-
Query interface: HTTP /api/v1/command/test
-
Query language: Cypher / OpenCypher
-
Differential comparison target:
Description
ArcadeDB returns wrong results when a COUNT {} block subquery is used inside the WHERE clause of a pattern comprehension.
The COUNT {} predicate should filter the rows produced by the pattern comprehension. Instead, ArcadeDB returns all rows, as if the WHERE COUNT { ... } condition were not applied.
This is not the same as the inline relationship-property filter issues. The failing query does not use an inline property filter. The issue appears specific to evaluating a block subquery predicate inside pattern-comprehension WHERE.
The same COUNT {} logic works correctly in a CALL subquery.
To reproduce
Run from a clean database.
1. Setup
MATCH (n) DETACH DELETE n;
CREATE
(a:CB {name: 'a'}),
(b:CB {name: 'b'}),
(c:CB {name: 'c'}),
(d:CB {name: 'd'}),
(a)-[:E {w: 1}]->(b),
(a)-[:E {w: 2}]->(c),
(b)-[:E {w: 3}]->(d);
Graph structure:
So among the two nodes reached from a:
b has 1 outgoing E edge
c has 0 outgoing E edges
2. Failing query: COUNT{} = 0
MATCH (a:CB {name: 'a'})
RETURN [
(a)-[:E]->(b:CB)
WHERE COUNT { MATCH (b)-[:E]->(:CB) } = 0
| b.name
] AS names;
Expected behavior
The pattern comprehension iterates over b and c.
For each candidate:
b: COUNT { MATCH (b)-[:E]->(:CB) } = 1 => exclude for = 0
c: COUNT { MATCH (c)-[:E]->(:CB) } = 0 => include for = 0
Expected result:
Neo4j 2026.05.0 returns:
Actual behavior
ArcadeDB returns both nodes:
names = ['c', 'b'] -- order may vary
The COUNT{} = 0 predicate does not filter out b.
Additional failing predicates
The same setup also fails with other COUNT {} comparisons.
MATCH (a:CB {name: 'a'})
RETURN [
(a)-[:E]->(b:CB)
WHERE COUNT { MATCH (b)-[:E]->(:CB) } = 1
| b.name
] AS names;
Expected:
ArcadeDB:
['c', 'b'] -- order may vary
MATCH (a:CB {name: 'a'})
RETURN [
(a)-[:E]->(b:CB)
WHERE COUNT { MATCH (b)-[:E]->(:CB) } > 0
| b.name
] AS names;
Expected:
ArcadeDB:
['c', 'b'] -- order may vary
Summary:
Predicate inside PC WHERE |
Expected |
ArcadeDB |
COUNT { MATCH (b)-[:E]->(:CB) } = 0 |
['c'] |
['c', 'b'] |
COUNT { MATCH (b)-[:E]->(:CB) } = 1 |
['b'] |
['c', 'b'] |
COUNT { MATCH (b)-[:E]->(:CB) } > 0 |
['b'] |
['c', 'b'] |
Control 1: ordinary PC WHERE filter works
A normal predicate using the pattern-comprehension variable works correctly:
MATCH (a:CB {name: 'a'})
RETURN [
(a)-[:E]->(b:CB)
WHERE b.name = 'c'
| b.name
] AS names;
ArcadeDB result:
So the pattern-comprehension WHERE clause itself is not ignored in general.
Control 2: equivalent CALL subquery works
The same COUNT {} logic works correctly inside a CALL subquery:
MATCH (a:CB {name: 'a'})
CALL {
WITH a
MATCH (a)-[:E]->(b:CB)
WHERE COUNT { MATCH (b)-[:E]->(:CB) } = 0
RETURN b.name AS n
}
RETURN collect(n) AS names;
ArcadeDB result:
This confirms that ArcadeDB can evaluate the same COUNT {} predicate correctly outside pattern comprehension.
Control 3: explicit CALL result for all candidates
This query shows the expected per-candidate counts:
MATCH (a:CB {name: 'a'})
CALL {
WITH a
MATCH (a)-[:E]->(b:CB)
RETURN b.name AS name, COUNT { MATCH (b)-[:E]->(:CB) } AS out_count
}
RETURN name, out_count
ORDER BY name;
Expected and ArcadeDB result:
name='b', out_count=1
name='c', out_count=0
So the count logic itself is correct when evaluated in a normal subquery context.
Cross-engine comparison
Failing query:
MATCH (a:CB {name: 'a'})
RETURN [
(a)-[:E]->(b:CB)
WHERE COUNT { MATCH (b)-[:E]->(:CB) } = 0
| b.name
] AS names;
| Engine |
Result |
Neo4j 2026.05.0 |
['c'] |
ArcadeDB 26.7.2-SNAPSHOT |
['c', 'b'] |
Summary
| Context |
Query shape |
ArcadeDB |
PC WHERE b.name = 'c' |
normal predicate over PC variable |
correct |
PC WHERE COUNT { MATCH (b)-[:E]->(...) } = 0 |
block subquery predicate over PC variable |
wrong, returns all PC rows |
CALL with same COUNT {} predicate |
normal subquery context |
correct |
CALL returning per-candidate COUNT {} |
count evaluation itself |
correct |
Why this looks like a bug
The pattern-comprehension WHERE clause works for ordinary predicates, and the same COUNT {} expression works in a CALL subquery.
The failure appears specific to COUNT {} block subqueries inside pattern-comprehension WHERE.
The observed behavior is consistent with the COUNT {} predicate being ignored or mis-evaluated inside the pattern-comprehension filter. I am avoiding a stronger root-cause claim here, because the result pattern does not uniquely prove whether this is a scope-capture bug or a predicate-lowering bug.
ArcadeDB version
Observed on latest Docker image:
Environment
Host OS: Linux
5.4.0-216-genericDeployment: Docker
arcadedata/arcadedb:latestQuery interface: HTTP
/api/v1/command/testQuery language: Cypher / OpenCypher
Differential comparison target:
2026.05.0Description
ArcadeDB returns wrong results when a
COUNT {}block subquery is used inside theWHEREclause of a pattern comprehension.The
COUNT {}predicate should filter the rows produced by the pattern comprehension. Instead, ArcadeDB returns all rows, as if theWHERE COUNT { ... }condition were not applied.This is not the same as the inline relationship-property filter issues. The failing query does not use an inline property filter. The issue appears specific to evaluating a block subquery predicate inside pattern-comprehension
WHERE.The same
COUNT {}logic works correctly in aCALLsubquery.To reproduce
Run from a clean database.
1. Setup
Graph structure:
So among the two nodes reached from
a:2. Failing query:
COUNT{} = 0Expected behavior
The pattern comprehension iterates over
bandc.For each candidate:
Expected result:
Neo4j
2026.05.0returns:Actual behavior
ArcadeDB returns both nodes:
The
COUNT{} = 0predicate does not filter outb.Additional failing predicates
The same setup also fails with other
COUNT {}comparisons.Expected:
ArcadeDB:
Expected:
ArcadeDB:
Summary:
WHERECOUNT { MATCH (b)-[:E]->(:CB) } = 0['c']['c', 'b']COUNT { MATCH (b)-[:E]->(:CB) } = 1['b']['c', 'b']COUNT { MATCH (b)-[:E]->(:CB) } > 0['b']['c', 'b']Control 1: ordinary PC
WHEREfilter worksA normal predicate using the pattern-comprehension variable works correctly:
ArcadeDB result:
So the pattern-comprehension
WHEREclause itself is not ignored in general.Control 2: equivalent
CALLsubquery worksThe same
COUNT {}logic works correctly inside aCALLsubquery:ArcadeDB result:
This confirms that ArcadeDB can evaluate the same
COUNT {}predicate correctly outside pattern comprehension.Control 3: explicit
CALLresult for all candidatesThis query shows the expected per-candidate counts:
Expected and ArcadeDB result:
So the count logic itself is correct when evaluated in a normal subquery context.
Cross-engine comparison
Failing query:
2026.05.0['c']26.7.2-SNAPSHOT['c', 'b']Summary
WHERE b.name = 'c'WHERE COUNT { MATCH (b)-[:E]->(...) } = 0CALLwith sameCOUNT {}predicateCALLreturning per-candidateCOUNT {}Why this looks like a bug
The pattern-comprehension
WHEREclause works for ordinary predicates, and the sameCOUNT {}expression works in aCALLsubquery.The failure appears specific to
COUNT {}block subqueries inside pattern-comprehensionWHERE.The observed behavior is consistent with the
COUNT {}predicate being ignored or mis-evaluated inside the pattern-comprehension filter. I am avoiding a stronger root-cause claim here, because the result pattern does not uniquely prove whether this is a scope-capture bug or a predicate-lowering bug.