-
Notifications
You must be signed in to change notification settings - Fork 413
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
Recommended way to create a graph from a table or SQL query #289
Comments
The recommended way would be to use cypher commands, not SQL commands. So, you would create the graph, then create and connect the vertices and edges (relationships). It is not recommended to attempt to create the graph yourself with SQL commands. |
(Just to clarify, I'm not trying to modify the underlying system tables directly in any way.) So if I understand correctly, there is no easy/convenient way to populate graphs from the results of SQL queries?
If so, this feels quite inefficient, but perhaps I'm missing something. |
Yes, that is the recommended way, atm. Currently, there isn't a function or functionality that could cast a set of tables and data into a graph. However, it is something that we have been discussing on occasion. We should probably revisit it to see if it is feasible. |
I have added it as a task for review and -> possible <- implementation in the future. However, anything that it were to do would just be a codified selection from tables, building Cypher commands, and then executing those commands. |
Ok, thanks for the info. Perhaps something like this could be worth considering: select create_vertex('g', id, label, properties) from (select id, label, properties from (...)) as r;
select create_edge('g', id, label, start_id, end_id, properties) from (select id, label, start_id, end_id, properties from (...)) as r; where Would you prefer this issue be closed or left open? |
Hello.
What is the recommended way to create a graph from a table (or from an SQL query, in general)?
Say, we have a table
A
with fieldsid
andparent_id
, where the latter refers back to the former of some row.How would I go about and cast this into an AGE graph easily?
Ideally, this would be without doing a client-server roundtrip of first querying table rows and then creating the corresponding graph vertices and edges.
Currently, there seems to be a way to load graphs from CSV files (https://age.apache.org/age-manual/master/intro/agload.html), but this doesn't really help in this case.
Also, there seems to be a helper function written in plpython available (https://github.com/sorrell/age-compose/blob/master/docker-entrypoint/initdb.d/20-initgraph.sql#L10-L37), but this isn't ideal either.
Best regards.
The text was updated successfully, but these errors were encountered: