Open MatheusFarias03 opened 1 year ago
When I run the query that you provided, it is placed correctly under node label. Could you make sure if you've cloned from main branch or share the order of query execution?
Sure! When I type git status
on the terminal, it shows that I'm on the main
branch:
git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
Now, how I am executing the query.
First, I created the graph:
SELECT * FROM ag_catalog.create_graph('goodreads_db');
Then I created a "User" vertex:
SELECT * FROM cypher ('goodreads_db', $$
CREATE (a :User {first_name: 'Matheus', last_name: 'Matsumoto', country: 'Brazil', read: 9, reading:2 }) RETURN a
$$) as (a agtype);
I also created a "Book" vertex:
SELECT * FROM cypher ('goodreads_db', $$
CREATE (a :Book {title: 'To Kill a Mockingbird', author: 'Harper Lee', rating: 4.27, pages: 336, language: 'English', ratings: 5574002, reviews: 107847})
RETURN a
$$) as (a agtype);
And after this, I created an edge between "User" and "Book" with a "READ" label:
SELECT * FROM cypher ('goodreads_db', $$
MATCH (a :User), (b :Book)
WHERE a.first_name = 'Matheus' AND b.title = 'To Kill a Mockingbird'
CREATE (a)-[e:READ {rating: 4}]->(b)
RETURN e
$$) as (e agtype);
So I kept doing it like this, also adding the vertices with "Author" label and adding the edge with "AUTHOR_OF" label between them. Now I have about 17 nodes and 22 edges. I went to where I installed AGE Viewer and executed the npm run setup
and npm run start
commands to use AGE Viewer.
Thank you for providing it. I keep running the queries in the provided order above and it seems that I get the correct result.
I'd just like to make sure if you run these queries using query editor in viewer app. If not, could you tell me how you run these queries (ex: using pgadmin, cmd) so that I can see if I get the same bug?
I did the addition of vertices and edges with the terminal app. Then, just to visualize the graph, I went to AGE Viewer. I believe that some nodes may have been added whilst AGE Viewer was running, but I added them via terminal. I do not know if this affects this behavior or not.
So, I open the Terminal App, go to the postgres directory, and then I type:
% bin/pg_ctl -D demo -l logfile start
waiting for server to start.... done
server started
% bin/psql demo
psql (11.17)
Type "help" for help.
demo=#
And then I start using AGE to create the graph, nodes, and edges.
Oh and I forgot to add that I'm using:
@MatheusFarias03 This might be specific to postgres version 11 as there's two separate queries for metadata. The query that is executed depends on the connected pg version. Do you experience the same issue when using postgres version 12?
I did not try it with postgres version 12.
I'm also using postgres version 11 and I get the correct result. This is the data output from query for the version 11 metadata.
I've looked at the backend code and I believe it determines vertices and edges based on kind column. I think each rows from the data output represents whether label is vertex or edge properly. So I'm curious how this issue occurred if it is caused by the version of postgres.
I was looking at other issues and this bug actually happened here : #77 , but someone there said that also had the same bug at #71 and that #75 should fix the bug, but it occurred again here.
If possible, could you run this query in your terminal and share the output result?
SELECT * FROM (
SELECT c.relname AS label, n.oid as namespace_id, c.reltuples AS cnt
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n
ON n.oid = c.relnamespace
WHERE c.relkind = 'r'
AND n.nspname = 'goodreads_db'
) as q1
JOIN ag_graph as g ON q1.namespace_id = g.namespace
INNER JOIN ag_label as label
ON label.name = q1.label
AND label.graph = g.oid;
Thank you
Running the query it outputs this:
label | namespace_id | cnt | name | namespace | name | graph | id | kind | relation
-------------------+--------------+-----+--------------+--------------+-------------------+-------+----+------+----------------------------------
AUTHOR_OF | 17439 | 13 | goodreads_db | goodreads_db | AUTHOR_OF | 17442 | 7 | e | goodreads_db."AUTHOR_OF"
Author | 17439 | 5 | goodreads_db | goodreads_db | Author | 17442 | 6 | v | goodreads_db."Author"
Book | 17439 | 13 | goodreads_db | goodreads_db | Book | 17442 | 4 | v | goodreads_db."Book"
CURRENTLY_READING | 17439 | 2 | goodreads_db | goodreads_db | CURRENTLY_READING | 17442 | 8 | e | goodreads_db."CURRENTLY_READING"
READ | 17439 | 9 | goodreads_db | goodreads_db | READ | 17442 | 5 | e | goodreads_db."READ"
User | 17439 | 1 | goodreads_db | goodreads_db | User | 17442 | 3 | v | goodreads_db."User"
_ag_label_edge | 17439 | 0 | goodreads_db | goodreads_db | _ag_label_edge | 17442 | 2 | e | goodreads_db._ag_label_edge
_ag_label_vertex | 17439 | 0 | goodreads_db | goodreads_db | _ag_label_vertex | 17442 | 1 | v | goodreads_db._ag_label_vertex
(8 rows)
The result looks correct to me and now I have about 80nodes and 100 more edges, but I still get the correct result. I've tested with both pg version 11 and 12 on window and ubuntu environment and worked fine. I think there might be some other factor that trigger vertices turning into edges but it's difficult for me to find out the bug at this moment. I'd suggest you to do the following.
Thank you for reporting this bug and I'm sorry I couldn't be more helpful.
No worries! I'll try it again with postgres version 12 and write here if I stumble on any bugs.
Bug Description
I've created a graph to replicate the Goodreads website, where you can keep track of your current readings and give ratings to books. The graph's name is "goodreads_db" and the vertices can be of the following labels: "Book", "Author", and "User". When I open AGE Viewer, only "*" and "User" are available on the "Node Label" panel, both "Book" and "Author" appear on the "Edge Label" panel (which are wrongly put since both of them belong to "Node Label").
Furthermore, when I click on the "Book(11)" or "Author(5)" button, it creates a query but it places the "Book" label as an edge label:
Here is an example of how I'm adding these "Book" vertices:
Expected behavior
The "Book" and "Author" label should be placed under "Node Label", so that when I click it, it would create a query like this:
When I type this query manually, the right behavior is shown: