Describe the bug
ORDER BY may fail on Apache AGE when it references a property of a node value returned under an alias.
In the minimized repro below, the query returns n AS person and then sorts by person.name. Neo4j and Memgraph both accept this and return the expected rows.
Instead, AGE fails with:
could not find rte for person
and reports that person is out of scope.
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?
SELECT * FROM cypher('fuzz_graph', $$
CREATE (:Person {name: 'Alice'}),
(:Person {name: 'Bob'}),
(:Person {name: 'Charlie'})
$$) AS (v agtype);
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', $$
MATCH (n:Person)
RETURN n AS person
ORDER BY person.name DESC
LIMIT 2
$$) AS (person agtype);
Returned result on AGE:
ERROR: could not find rte for person
HINT: variable person does not exist within scope of usage
Expected behavior
The query should succeed and return the two lexicographically largest Person nodes by name.
Observed behavior on Neo4j and Memgraph:
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
Two nearby control cases behave correctly on the same AGE instance:
- Sorting by the original variable instead of the return alias:
SELECT * FROM cypher('fuzz_graph', $$
MATCH (n:Person)
RETURN n AS person
ORDER BY n.name DESC
LIMIT 2
$$) AS (person agtype);
AGE returns the expected two rows there.
- Sorting by a scalar alias also works:
SELECT * FROM cypher('fuzz_graph', $$
MATCH (n:Person)
RETURN n.name AS person
ORDER BY person DESC
LIMIT 2
$$) AS (person agtype);
AGE also returns:
So the issue appears specific to property access through a return alias that holds a node value, rather than to ORDER BY aliases in general.
Describe the bug
ORDER BYmay fail on Apache AGE when it references a property of a node value returned under an alias.In the minimized repro below, the query returns
n AS personand then sorts byperson.name. Neo4j and Memgraph both accept this and return the expected rows.Instead, AGE fails with:
and reports that
personis out of scope.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?
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 query should succeed and return the two lexicographically largest
Personnodes byname.Observed behavior on Neo4j and Memgraph:
Environment (please complete the following information):
1.7.018.1Additional context
Two nearby control cases behave correctly on the same AGE instance:
AGE returns the expected two rows there.
AGE also returns:
So the issue appears specific to property access through a return alias that holds a node value, rather than to
ORDER BYaliases in general.