ArcadeDB version
Observed on Docker images:
arcadedata/arcadedb:latest
arcadedata/arcadedb:26.4.1-SNAPSHOT
Environment
- Docker on Windows host
- ArcadeDB queried through the HTTP API:
/api/v1/command/arcade
- Requests sent in the same shape used by ArcadeDB Studio:
language: opencypher
serializer: studio
Describe the bug
COUNT { ... } pattern subqueries may return the bound node from the inner pattern instead of the integer count when the pattern uses a fresh variable.
In the repro below, dogCount should be a number:
Alice -> 1
Bob -> 1
Charlie -> 0
Neo4j returns those integer counts.
ArcadeDB instead returns the bound inner node p:
Alice, {name: 'Alice'}
Bob, {name: 'Bob'}
Charlie, {name: 'Charlie'}
So the count expression leaks the matched node value instead of producing an integer.
To Reproduce
Setup
CREATE (:Person {name:'Alice'}),
(:Person {name:'Bob'}),
(:Person {name:'Charlie'}),
(:Dog {name:'Rex'}),
(:Dog {name:'Fido'});
MATCH (p:Person {name:'Alice'}), (d:Dog {name:'Rex'})
CREATE (p)-[:OWNS]->(d);
MATCH (p:Person {name:'Bob'}), (d:Dog {name:'Fido'})
CREATE (p)-[:OWNS]->(d);
Query
MATCH (person:Person)
RETURN person.name AS name,
COUNT { (p:Person {name: person.name})-[:OWNS]->(:Dog) } AS dogCount
ORDER BY name;
Expected behavior
The result should be:
Alice, 1
Bob, 1
Charlie, 0
Actual behavior
ArcadeDB returns:
Alice, {name: 'Alice'}
Bob, {name: 'Bob'}
Charlie, {name: 'Charlie'}
So COUNT { ... } returns the inner matched node instead of an integer count.
Control cases
Control 1, ordinary aggregation behaves correctly on ArcadeDB:
MATCH (person:Person)
OPTIONAL MATCH (person)-[:OWNS]->(d:Dog)
RETURN person.name AS name, COUNT(d) AS dogCount
ORDER BY name;
Observed result on both Neo4j and ArcadeDB:
Alice, 1
Bob, 1
Charlie, 0
Control 2, the related COUNT { ... } form that reuses the outer variable does not return nodes, but still behaves incorrectly in a different way:
MATCH (person:Person)
RETURN person.name AS name,
COUNT { (person)-[:OWNS]->(:Dog) } AS dogCount
ORDER BY name;
Observed result on ArcadeDB:
Alice, null
Bob, null
Charlie, null
This suggests the problem is not just that COUNT { ... } returns null everywhere.
When a fresh variable is introduced inside the pattern, ArcadeDB instead leaks that bound variable as the result.
ArcadeDB version
Observed on Docker images:
arcadedata/arcadedb:latestarcadedata/arcadedb:26.4.1-SNAPSHOTEnvironment
/api/v1/command/arcadelanguage: opencypherserializer: studioDescribe the bug
COUNT { ... }pattern subqueries may return the bound node from the inner pattern instead of the integer count when the pattern uses a fresh variable.In the repro below,
dogCountshould be a number:Alice -> 1Bob -> 1Charlie -> 0Neo4j returns those integer counts.
ArcadeDB instead returns the bound inner node
p:So the count expression leaks the matched node value instead of producing an integer.
To Reproduce
Setup
Query
Expected behavior
The result should be:
Actual behavior
ArcadeDB returns:
So
COUNT { ... }returns the inner matched node instead of an integer count.Control cases
Control 1, ordinary aggregation behaves correctly on ArcadeDB:
Observed result on both Neo4j and ArcadeDB:
Control 2, the related
COUNT { ... }form that reuses the outer variable does not return nodes, but still behaves incorrectly in a different way:Observed result on ArcadeDB:
This suggests the problem is not just that
COUNT { ... }returnsnulleverywhere.When a fresh variable is introduced inside the pattern, ArcadeDB instead leaks that bound variable as the result.