ArcadeDB may return null for a COUNT { ... } pattern subquery instead of the expected integer count. (original) (raw)
ArcadeDB version
Verified on:
arcadedata/arcadedb:latestarcadedata/arcadedb:26.4.1-SNAPSHOT
Observed through the same request shape used by ArcadeDB Studio:
language: opencypherserializer: studio
Environment
- Docker on Windows host
- ArcadeDB queried through the HTTP API:
/api/v1/command/arcade - Request mode aligned with ArcadeDB Studio
- Neo4j used as the Cypher reference engine for comparison
Describe the bug
ArcadeDB may return null for a COUNT { ... } pattern subquery instead of the expected integer count.
In the repro below:
- Alice owns one Labrador
- Bob owns one non-Labrador dog
- Charlie owns one non-Labrador dog
Neo4j returns 1, 0, 0 for labCount.
ArcadeDB returns null for all three rows.
To Reproduce
Setup
CREATE (:Person {name: 'Alice', age: 30}), (:Person {name: 'Bob', age: 25}), (:Person {name: 'Charlie', age: 35}), (:Dog {name: 'Rex', breed: 'Labrador'}), (:Dog {name: 'Fido', breed: 'Poodle'}), (:Dog {name: 'Spot', breed: 'Dalmatian'});
MATCH (p:Person {name: 'Alice'}), (d:Dog {name: 'Rex'}) CREATE (p)-[:HAS_DOG]->(d);
MATCH (p:Person {name: 'Bob'}), (d:Dog {name: 'Fido'}) CREATE (p)-[:HAS_DOG]->(d);
MATCH (p:Person {name: 'Charlie'}), (d:Dog {name: 'Spot'}) CREATE (p)-[:HAS_DOG]->(d);
Query
MATCH (person:Person) RETURN person.name AS name, COUNT { (person)-[:HAS_DOG]->(dog:Dog) WHERE dog.breed = 'Labrador' } AS labCount ORDER BY labCount DESC;
Expected behavior
The result should be:
Alice, 1
Bob, 0
Charlie, 0
Actual behavior
ArcadeDB returns:
Alice, null
Bob, null
Charlie, null
Control cases
Control 1, the plain match without COUNT { ... } behaves correctly:
MATCH (person:Person)-[:HAS_DOG]->(dog:Dog) RETURN person.name AS name, dog.breed AS breed ORDER BY name;
Observed result:
Alice, Labrador
Bob, Poodle
Charlie, Dalmatian
Control 2, counting all dogs with ordinary aggregation also behaves correctly:
MATCH (person:Person) OPTIONAL MATCH (person)-[:HAS_DOG]->(dog:Dog) RETURN person.name AS name, COUNT(dog) AS dogCount ORDER BY name;
Observed result:
Alice, 1
Bob, 1
Charlie, 1
This suggests the issue is specifically tied to COUNT { pattern WHERE ... }, not to the underlying data or to ordinary COUNT(...).