Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If an alias is not specified, the count result is incorrect. #945

Closed
beamrock opened this issue May 24, 2023 · 9 comments
Closed

If an alias is not specified, the count result is incorrect. #945

beamrock opened this issue May 24, 2023 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@beamrock
Copy link

beamrock commented May 24, 2023

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.

@beamrock beamrock added the bug Something isn't working label May 24, 2023
@AbdulSamad4068
Copy link

AbdulSamad4068 commented May 26, 2023

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

@jrgemignani
Copy link
Contributor

This is something that needs to be fixed.

@jrgemignani
Copy link
Contributor

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=#

@jrgemignani
Copy link
Contributor

I will look at this.

@jrgemignani
Copy link
Contributor

I will have a PR for this tomorrow.

@jrgemignani
Copy link
Contributor

PR #1288 has been created to address this.

@jrgemignani
Copy link
Contributor

@beamrock This has been corrected in the master branch.

Copy link

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.

@github-actions github-actions bot added the Stale Stale issues/PRs label May 11, 2024
@MuhammadTahaNaveed MuhammadTahaNaveed removed the Stale Stale issues/PRs label May 11, 2024
@MuhammadTahaNaveed
Copy link
Member

Closing this as it was resolved by PR #1288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

4 participants