Describe the bug
sum(...) may mishandle null inputs.
In Apache AGE, sum(null) returns null instead of 0, and sum(x) over a list containing both numbers and null may fail with:
arguments must resolve to a number
On both Neo4j and Memgraph, sum ignores null inputs and returns a numeric result.
How are you accessing AGE (Command line, driver, etc.)?
- PostgreSQL
cypher(...) wrapper through the local Python differential-testing harness
- Reproducible directly in
psql inside the Docker container
What data setup do we need to do?
No graph data is required beyond creating an empty graph:
SELECT create_graph('fuzz_graph');
What is the necessary configuration info needed?
- Plain Apache AGE Docker image was enough
- Docker image in local repro:
apache/age
- AGE extension version:
1.7.0
- PostgreSQL version:
18.1
- Graph name used in repro:
fuzz_graph
- No extra extensions or special configuration were required
What is the command that caused the error?
SELECT * FROM cypher('fuzz_graph', $$
RETURN sum(null) AS v
$$) AS (v agtype);
Returned result on AGE:
Expected behavior
The result should be:
Neo4j returns 0, and Memgraph also returns 0.
Environment (please complete the following information):
- Version: Apache AGE
1.7.0
- PostgreSQL:
18.1
- Host OS: Windows
- Architecture: x86_64
- Deployment: Docker
Additional context
A second variant shows the same issue more strongly:
SELECT * FROM cypher('fuzz_graph', $$
UNWIND [1,null,2] AS x
RETURN sum(x) AS v
$$) AS (v agtype);
Apache AGE returns:
ERROR: arguments must resolve to a number
Expected result:
Neo4j returns 3, and Memgraph also returns 3.
Other nearby control cases behave as expected on the same AGE instance:
- Summing a non-null number works:
SELECT * FROM cypher('fuzz_graph', $$
RETURN sum(1) AS v
$$) AS (v agtype);
Observed result:
avg(null) still returns null, which is expected:
SELECT * FROM cypher('fuzz_graph', $$
RETURN avg(null) AS v
$$) AS (v agtype);
Observed result:
- Even the single-null
UNWIND case differs from Neo4j and Memgraph:
SELECT * FROM cypher('fuzz_graph', $$
UNWIND [null] AS x
RETURN sum(x) AS v
$$) AS (v agtype);
Apache AGE returns:
while Neo4j and Memgraph both return:
So the issue appears to be specifically in how Apache AGE's sum aggregate handles null-valued inputs.
Describe the bug
sum(...)may mishandlenullinputs.In Apache AGE,
sum(null)returnsnullinstead of0, andsum(x)over a list containing both numbers andnullmay fail with:On both Neo4j and Memgraph,
sumignores null inputs and returns a numeric result.How are you accessing AGE (Command line, driver, etc.)?
cypher(...)wrapper through the local Python differential-testing harnesspsqlinside the Docker containerWhat data setup do we need to do?
No graph data is required beyond creating an empty graph:
What is the necessary configuration info needed?
apache/age1.7.018.1fuzz_graphWhat is the command that caused the error?
Returned result on AGE:
Expected behavior
The result should be:
Neo4j returns
0, and Memgraph also returns0.Environment (please complete the following information):
1.7.018.1Additional context
A second variant shows the same issue more strongly:
Apache AGE returns:
Expected result:
Neo4j returns
3, and Memgraph also returns3.Other nearby control cases behave as expected on the same AGE instance:
Observed result:
avg(null)still returnsnull, which is expected:Observed result:
UNWINDcase differs from Neo4j and Memgraph:Apache AGE returns:
while Neo4j and Memgraph both return:
So the issue appears to be specifically in how Apache AGE's
sumaggregate handles null-valued inputs.