Skip to content

Simple CASE expr WHEN value in WHERE returns no rows while equivalent generic CASE works #5083

Closed

Description

@shulei5831sl

ArcadeDB version

Observed on local Docker image:

docker inspect arcadedb -> arcadedata/arcadedb:latest sha256:2f63d3ebbf08d64fb9f51ae1ef7a45bee9938a43fb862d09053e0ac47e975b5b

docker exec arcadedb find /home/arcadedb/lib -name 'arcadedb-server-*.jar'
/home/arcadedb/lib/arcadedb-server-26.7.2-SNAPSHOT.jar

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

Also reproduced in a fresh isolated Docker container:

container: arcadedb_iso_20260707
image: arcadedata/arcadedb:latest
image digest: sha256:2f63d3ebbf08d64fb9f51ae1ef7a45bee9938a43fb862d09053e0ac47e975b5b
published port: 127.0.0.1:2490 -> 2480/tcp
server log: ArcadeDB Server v26.7.2-SNAPSHOT
build 852e924bf9c3d9839ac68009bc2ec923c5a58560/1783386683756/main

Environment

  • Host OS: Linux
  • Deployment: Docker
  • Query interface: HTTP /api/v1/command/test
  • Query language: Cypher / OpenCypher
  • Differential comparison targets:
    • Neo4j Community 2026.05.0
    • Neo4j Community 5.26.28
    • Memgraph 3.11.0
    • FalkorDB graph module 41811

Description

ArcadeDB returns the wrong result for the Cypher simple CASE form:

CASE expr WHEN value THEN ... ELSE ... END

when the expression is used inside a WHERE predicate.

On the same graph, the semantically equivalent generic CASE form:

CASE WHEN expr = value THEN ... ELSE ... END

returns the correct rows.

A direct comparison predicate also returns the correct rows.

This is a silent wrong-result bug: the query succeeds without an error, but returns an empty result set.

To reproduce

Run from a clean database.

If using the HTTP command endpoint, submit each Cypher statement separately, in order.

1. Clean database

MATCH (n) DETACH DELETE n;

2. Create test data

CREATE
  (n1:BugNode {id: 1, val: 10}),
  (n2:BugNode {id: 2, val: 50}),
  (n3:BugNode {id: 3, val: 30}),
  (n4:BugNode {id: 4, val: 10});

3. Run the failing query

MATCH (n:BugNode)
WHERE CASE n.val
        WHEN 10 THEN 'low'
        WHEN 50 THEN 'high'
        ELSE 'mid'
      END = 'low'
RETURN n.id AS id, n.val AS val
ORDER BY id;

Expected behavior

The simple CASE expression should map:

val = 10 -> 'low'
val = 50 -> 'high'
otherwise -> 'mid'

Therefore, the query should return the two nodes where val = 10:

id | val
---+----
1  | 10
4  | 10

Neo4j 2026.05.0, Neo4j 5.26.28, Memgraph 3.11.0, and FalkorDB 41811 return the expected two rows.

Actual behavior

ArcadeDB returns an empty result:

[]

No error or warning is reported.

Control queries that pass on ArcadeDB

Control 1: equivalent generic CASE

MATCH (n:BugNode)
WHERE CASE
        WHEN n.val = 10 THEN 'low'
        WHEN n.val = 50 THEN 'high'
        ELSE 'mid'
      END = 'low'
RETURN n.id AS id, n.val AS val
ORDER BY id;

ArcadeDB result:

[{id: 1, val: 10}, {id: 4, val: 10}]

Control 2: direct comparison predicate

MATCH (n:BugNode)
WHERE n.val = 10
RETURN n.id AS id, n.val AS val
ORDER BY id;

ArcadeDB result:

[{id: 1, val: 10}, {id: 4, val: 10}]

Cross-engine comparison

The failing query:

MATCH (n:BugNode)
WHERE CASE n.val
        WHEN 10 THEN 'low'
        WHEN 50 THEN 'high'
        ELSE 'mid'
      END = 'low'
RETURN n.id AS id, n.val AS val
ORDER BY id;

returns the expected result on the reference engines:

Neo4j 2026.05.0: [{id: 1, val: 10}, {id: 4, val: 10}]
Neo4j 5.26.28:   [{id: 1, val: 10}, {id: 4, val: 10}]
Memgraph 3.11.0: [{id: 1, val: 10}, {id: 4, val: 10}]
FalkorDB 41811:  [{id: 1, val: 10}, {id: 4, val: 10}]
ArcadeDB:        []

Isolated recheck

The same behavior was reproduced in a fresh isolated Docker container with no reused database state:

container: arcadedb_iso_20260707
image: arcadedata/arcadedb:latest
image digest: sha256:2f63d3ebbf08d64fb9f51ae1ef7a45bee9938a43fb862d09053e0ac47e975b5b
published port: 127.0.0.1:2490 -> 2480/tcp

isolated recheck:
simple_case_ids = []
generic_case_ids = [1, 4]
direct_where_ids = [1, 4]

Why this looks like a bug

The failing query and the generic CASE control are semantically equivalent for non-null numeric values:

CASE n.val
  WHEN 10 THEN 'low'
  WHEN 50 THEN 'high'
  ELSE 'mid'
END

should behave like:

CASE
  WHEN n.val = 10 THEN 'low'
  WHEN n.val = 50 THEN 'high'
  ELSE 'mid'
END

on this dataset.

The generic CASE expression and direct predicate both return the correct two rows, so the data, label scan, property access, and direct comparison logic are working. The failure appears specific to simple CASE expr WHEN value evaluation inside a WHERE predicate.

Related but distinct issue

This is related to, but distinct from, #3922.

That issue concerned null semantics for:

CASE null WHEN null THEN ...

This report is about a current non-null simple CASE predicate failure in ArcadeDB 26.7.2-SNAPSHOT:

CASE n.val WHEN 10 THEN ...

where n.val is a non-null numeric property.

Activity

  1. self-assigned this
    on Jul 7, 2026
  2. added theissue type on Jul 7, 2026
  3. added this to the 26.7.2 milestone on Jul 7, 2026
  4. added 2 commits that reference this issue on Jul 7, 2026
  5. lvca commented on Jul 7, 2026

    @lvca
    Member

    Confirmed and fixed in main.

    The simple form `CASE n.val WHEN 10 ...` compared `n.val` against each `WHEN` value using strict Java equality, which treats an integer property and a number literal as different when they are stored as different numeric types. In a `WHERE` clause this silently filtered out the matching rows, while the generic `CASE WHEN n.val = 10 ...` form worked because it uses the standard `=` comparison.

    The `WHEN` matching now uses that same `=` comparison, so both CASE forms behave identically (and consistently with Neo4j). The fix ships in the next release.

    Thanks for the clear report and cross-engine checks.

  6. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions