Skip to content

An existential pattern predicate in WHERE may fail to filter rows by the target node pattern. #3938

@Silence6666668

Description

@Silence6666668

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

An existential pattern predicate in WHERE may fail to filter rows by the target node pattern.

In the repro below, only Alice and Charlie live in Germany.
Bob lives only in United Kingdom, so he should not satisfy:

(p)-[:LIVING_IN]->(:Country {name: 'Germany'})

Neo4j filters Bob out correctly.
ArcadeDB still keeps Bob, which then leaks into later results.

To Reproduce

Setup

CREATE (:Country {name: 'Germany'}),
       (:Country {name: 'United Kingdom'}),
       (:Person {name: 'Alice'}),
       (:Person {name: 'Bob'}),
       (:Person {name: 'Charlie'});

MATCH (p:Person {name: 'Alice'}), (c:Country {name: 'Germany'})
CREATE (p)-[:LIVING_IN]->(c);

MATCH (p:Person {name: 'Bob'}), (c:Country {name: 'United Kingdom'})
CREATE (p)-[:LIVING_IN]->(c);

MATCH (p:Person {name: 'Charlie'}), (c:Country {name: 'Germany'})
CREATE (p)-[:LIVING_IN]->(c);

Query

MATCH (p:Person)
WHERE (p)-[:LIVING_IN]->(:Country {name: 'Germany'})
RETURN collect(p.name) AS people;

Expected behavior

Only the two people connected to Germany should remain:

["Alice", "Charlie"]

Actual behavior

ArcadeDB returns:

["Alice", "Bob", "Charlie"]

So Bob incorrectly passes the WHERE predicate even though he only lives in United Kingdom.

Stronger variant

The leaked row also affects downstream matching and aggregation:

MATCH (p:Person)
WHERE (p)-[:LIVING_IN]->(:Country {name: 'Germany'})
WITH p
MATCH (p)-[:LIVING_IN]->(c:Country)
RETURN c.name AS country, count(*) AS cnt
ORDER BY country;

Expected:

Germany, 2

Observed on ArcadeDB:

Germany, 2
United Kingdom, 1

Neo4j returns only Germany, 2.

Control case

If the same constraint is expressed using an explicit match and a normal property filter, ArcadeDB behaves correctly:

MATCH (p:Person)-[:LIVING_IN]->(c:Country)
WHERE c.name = 'Germany'
WITH p
MATCH (p)-[:LIVING_IN]->(c2:Country)
RETURN c2.name AS country, count(*) AS cnt
ORDER BY country;

Observed result on both Neo4j and ArcadeDB:

Germany, 2

This suggests the issue is specifically tied to the existential pattern predicate inside WHERE, not to the later grouping query.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions