age
age copied to clipboard
If an alias is not specified, the count result is incorrect.
Describe the bug If an alias is not specified, the count result is incorrect.
How are you accessing AGE (Command line, driver, etc.)?
- anywhere. I did in Command line.
What data setup do we need to do?
SELECT * from cypher('movie_graph', $$
CREATE (a:Part {part_num: '123'}),
(b:Part {part_num: '345'}),
(c:Part {part_num: '456'}),
(d:Part {part_num: '789'})
$$) as (a agtype);
moviedb=# SELECT * from cypher('movie_graph', $$ match (a:Part) return a $$) as (result agtype);
result
--------------------------------------------------------------------------------------
{"id": 1125899906842625, "label": "Part", "properties": {"part_num": "123"}}::vertex
{"id": 1125899906842626, "label": "Part", "properties": {"part_num": "345"}}::vertex
{"id": 1125899906842627, "label": "Part", "properties": {"part_num": "456"}}::vertex
{"id": 1125899906842628, "label": "Part", "properties": {"part_num": "789"}}::vertex
(4 rows)
What is the command that caused the error?
When an alias is not specified
moviedb=# SELECT * from cypher('movie_graph', $$ match (:Part) return count(*) $$) as (result agtype);
result
--------
1 <-------- incorrect count result
(1 row)
When an alias and a label is specified
moviedb=# SELECT * from cypher('movie_graph', $$ match (a:Part) return count(*) $$) as (result agtype);
result
--------
4
(1 row)
When only an alias is specified
moviedb=# SELECT * from cypher('movie_graph', $$ match (a) return count(*) $$) as (result agtype);
result
--------
4
(1 row)
Expected behavior
Same as agensgraph or neo4j
On Neo4j
neo4j@ldbcgraph> match (:Part) return count(*) ;
+----------+
| count(*) |
+----------+
| 4 |
+----------+
On AgensGraph
sampledb=# match (:Part) return count(*) ;
count
-------
4
Additional context
Just so you know, agensgraph and neo4j give accurate results.
I encountered a similar problem and decided to seek assistance on Stack Overflow. I suggest exploring the various solutions provided there to address the issue. https://stackoverflow.com/questions/76327413/ambiguous-count-results-in-apache-agedb-cypher-query-when-alias-is-not-defined
This is something that needs to be fixed.
Verified this is still an issue -
psql-15.4-5432-pgsql=# SELECT create_graph('movie_graph');
NOTICE: graph "movie_graph" has been created
create_graph
--------------
(1 row)
psql-15.4-5432-pgsql=# SELECT * from cypher('movie_graph', $$
psql-15.4-5432-pgsql$# CREATE (a:Part {part_num: '123'}),
psql-15.4-5432-pgsql$# (b:Part {part_num: '345'}),
psql-15.4-5432-pgsql$# (c:Part {part_num: '456'}),
psql-15.4-5432-pgsql$# (d:Part {part_num: '789'})
psql-15.4-5432-pgsql$# $$) as (a agtype);
a
---
(0 rows)
psql-15.4-5432-pgsql=# SELECT * from cypher('movie_graph', $$ match (a:Part) return a $$) as (result agtype);
result
-------------------------------------------------------------------------------------
{"id": 844424930131969, "label": "Part", "properties": {"part_num": "123"}}::vertex
{"id": 844424930131970, "label": "Part", "properties": {"part_num": "345"}}::vertex
{"id": 844424930131971, "label": "Part", "properties": {"part_num": "456"}}::vertex
{"id": 844424930131972, "label": "Part", "properties": {"part_num": "789"}}::vertex
(4 rows)
psql-15.4-5432-pgsql=# SELECT * from cypher('movie_graph', $$ match (:Part) return count(*) $$) as (result agtype);
result
--------
1
(1 row)
psql-15.4-5432-pgsql=# SELECT * from cypher('movie_graph', $$ match (a:Part) return count(*) $$) as (result agtype);
result
--------
4
(1 row)
psql-15.4-5432-pgsql=#
I will look at this.
I will have a PR for this tomorrow.
PR #1288 has been created to address this.
@beamrock This has been corrected in the master branch.
This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.
Closing this as it was resolved by PR #1288