Skip to content

all() over pattern-comprehension list returns wrong result on larger graphs #5145

Description

@shulei5831sl

ArcadeDB version

Observed on local Docker image:

docker inspect arcadedb -> arcadedata/arcadedb:latest
docker exec arcadedb find /home/arcadedb/lib -name 'arcadedb-server-*.jar'
/home/arcadedb/lib/arcadedb-server-26.7.2-SNAPSHOT.jar

ArcadeDB version: 26.7.2-SNAPSHOT
Build: f88429c1

Endpoint:
http://127.0.0.1:2480/api/v1/command/test

Environment

  • Host OS: Linux

  • Deployment: Docker

  • Query interface: HTTP /api/v1/command/test

  • Query language: Cypher

  • Differential comparison targets:

    • Neo4j Community 2026.05.0
    • Memgraph 3.11.0

Description

ArcadeDB returns the wrong result for all() when the input list is produced by a pattern comprehension.

The failing query collects each active user's friends' active values through a pattern comprehension, then flags users whose friend list is non-empty and contains only inactive friends:

MATCH (u:User {active: true})
WITH u, [(u)-[:FRIEND]->(f:User) | f.active] AS actives
WHERE size(actives) > 0 AND all(a IN actives WHERE a = false)
SET u.flagged = true;

On a small 6-node graph, ArcadeDB returns the correct result. On a deterministic 35-node graph generated with seed 42, the same query returns the wrong result.

The equivalent formulation using explicit MATCH + collect() works correctly on the same 35-node graph, which isolates the failure to the pattern-comprehension list used by all().

Neo4j and Memgraph return the expected result.

To reproduce

Run from a clean database.

1. Small graph baseline — correct on ArcadeDB

MATCH (n) DETACH DELETE n;

CREATE
  (u1:User {id:1, active:true}),
  (u2:User {id:2, active:true}),
  (u3:User {id:3, active:true}),
  (u4:User {id:4, active:false}),
  (u5:User {id:5, active:false}),
  (u6:User {id:6, active:false}),
  (u1)-[:FRIEND]->(u4),
  (u1)-[:FRIEND]->(u5),
  (u2)-[:FRIEND]->(u4),
  (u2)-[:FRIEND]->(u1),
  (u3)-[:FRIEND]->(u5),
  (u3)-[:FRIEND]->(u6);

Expected reasoning:

u1 friends: [false, false] => all inactive => flag
u2 friends: [false, true]  => has active   => do not flag
u3 friends: [false, false] => all inactive => flag

Query:

MATCH (u:User {active: true})
WITH u, [(u)-[:FRIEND]->(f:User) | f.active] AS actives
WHERE size(actives) > 0 AND all(a IN actives WHERE a = false)
SET u.flagged = true;

MATCH (u:User)
WHERE u.flagged = true
RETURN u.id AS id
ORDER BY id;

ArcadeDB result:

id = 1
id = 3

This is correct.

2. Larger graph — wrong result on ArcadeDB

The attached Python reproducer builds a deterministic 35-node graph using seed 42.

The graph contains:

20 active User nodes
15 inactive User nodes
random FRIEND edges generated from seed 42

Run the same query:

MATCH (u:User {active: true})
WITH u, [(u)-[:FRIEND]->(f:User) | f.active] AS actives
WHERE size(actives) > 0 AND all(a IN actives WHERE a = false)
SET u.flagged = true;

MATCH (u:User)
WHERE u.flagged = true
RETURN count(*) AS cnt;

Expected behavior

On the 35-node graph generated with seed 42, exactly 2 active users have a non-empty friend list where all friends are inactive.

Expected result:

cnt = 2

Neo4j 2026.05.0 returns:

cnt = 2

Memgraph 3.11.0 returns:

cnt = 2

Actual behavior

ArcadeDB returns:

cnt = 0

No error or warning is reported.

Read-only diagnostic query

This query exposes the pattern-comprehension list and all() result per user without performing writes:

MATCH (u:User {active: true})
WITH u, [(u)-[:FRIEND]->(f:User) | f.active] AS actives
RETURN
  u.id AS id,
  actives,
  size(actives) AS sz,
  all(a IN actives WHERE a = false) AS all_inactive
ORDER BY id;

On the same 35-node graph, Neo4j and Memgraph identify 2 users with:

sz > 0
all_inactive = true

ArcadeDB returns all_inactive = false for those same expected users.

Control: explicit MATCH + collect() works on ArcadeDB

Using explicit MATCH + collect() instead of pattern comprehension returns the correct result on the same 35-node graph:

MATCH (u:User {active: true})-[:FRIEND]->(f:User)
WITH u, collect(f.active) AS actives
WHERE size(actives) > 0 AND all(a IN actives WHERE a = false)
RETURN count(DISTINCT u) AS cnt;

ArcadeDB result:

cnt = 2

So all() can evaluate correctly when the list is produced by collect(). The wrong result appears when the list is produced by pattern comprehension.

Cross-engine comparison

35-node graph, seed 42:

Engine Pattern comprehension + all()
Neo4j 2026.05.0 cnt = 2
Memgraph 3.11.0 cnt = 2
ArcadeDB 26.7.2-SNAPSHOT cnt = 0

Same graph, ArcadeDB only:

Query form ArcadeDB result
pattern comprehension + all() cnt = 0
explicit MATCH + collect() + all() cnt = 2

Summary

Query shape 6-node graph 35-node graph
pattern comprehension + all() correct wrong
explicit MATCH + collect() + all() correct correct

Why this looks like a bug

The query is semantically valid and returns the expected result on Neo4j and Memgraph.

ArcadeDB also returns the correct result on a small graph, and the equivalent MATCH + collect() formulation works correctly on the same 35-node graph.

The failure appears specific to the interaction between pattern-comprehension list evaluation and all() on the larger graph. I am not claiming a fixed threshold here; the attached deterministic reproducer is intended to make the failing graph state exact.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions