apache / age

Graph database optimized for fast analysis and real-time data processing. It is provided as an extension to PostgreSQL.
https://age.apache.org
Apache License 2.0
3.05k stars 407 forks source link

Age graph existance check function, something like "graph_exists" would be very nice #1936

Closed MironAtHome closed 2 months ago

MironAtHome commented 3 months ago

1 It would be very helpful to have an function that could report a boolean, whether graph with name "xyz" exists, true or false. In addition, I am not sure, if an optional parameter to the same, or a separate function, that would produce something like "residual", that could potentially cause "create_graph" to fail. One of the reasons, when "drop extension if exists age" is performed, existing graphs are forgotten. To clean up those one need to run "drop schema cascade;" Since internals of how graph is defined and stored in the database is really an private interface, it would be very nice to provide such a function, since details can potentially change from version to version, and it would be very helpful to graph user to have something like 'report_graph_residual()' with all the database objects related to the graph name, whether the graph itself considered existing or not at the moment. 2 Thinking of an ideal solution / alternate approach, having an overload of function cypher, that does not require graph name as the first parameter, but could accept something like "create graph ..." command, would be absolutely awesome, but that should not be taken either / or. The #1 is essential, #2 is a very nice language wise, to have a very concise was to express same query. Being very fond of cypher I thought it would be nice to add this to the ask, at least as in reverence to all the cypher language community.

rafsun42 commented 3 months ago

@MironAtHome If I understand correctly, when the extension is dropped, graph schemas are not dropped. And, you are expecting the graphs to be dropped automatically?

MironAtHome commented 3 months ago

See if function age_graph_exists here helps

MironAtHome commented 2 months ago

@rafsun42

If I understand correctly, when the extension is dropped, graph schemas are not dropped. And, you are expecting the graphs to be dropped automatically?

Not really. All I am asking for is to expose as public function callable from Postgres database SQL layer the function that already exists in the Age code "graph_exists" so that I could put in my procedures, working with data loading an check if not (age_graph_exists('')) then select create_graph(''); end if; rest is an attempt to gather simple and, potential, corner cases, to explain, as to why I feel this new function is justified. Rest is additional considerations with lower priority.

rafsun42 commented 2 months ago

@MironAtHome I created PR #1958. Please let me know if that works for you.

MironAtHome commented 2 months ago

Great thank you! I have commented for code review. Please take a look.

MironAtHome commented 2 months ago

I noted PR was merged into master. Closing issue. Please see if you still can make adjustments based on comments.

MironAtHome commented 2 months ago

@rafsun42 Updated function. Please see if changes in the code acceptable ( those are matching suggestions in the PR ).