You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@age.apache.org by "MatheusFarias03 (via GitHub)" <gi...@apache.org> on 2023/09/28 20:54:50 UTC
[GitHub] [age] MatheusFarias03 opened a new issue, #1254: Renaming a Label
MatheusFarias03 opened a new issue, #1254:
URL: https://github.com/apache/age/issues/1254
Hi! I was thinking about the possibility of a user wanting to rename a label, because there's a [page](https://neo4j.com/docs/apoc/current/graph-refactoring/rename-label-type-property/#rename-node-labels) in Neo4j's documentation dedicated to that. I tried just renaming the tables in Postgres, but I'm not sure if that's the correct way or if this may cause any errors. Here's what I've done:
```sql
-- Create the graph.
SELECT * FROM create_graph('PeopleGraph');
NOTICE: graph "PeopleGraph" has been created
create_graph
--------------
(1 row)
-- Create a "People" node label.
SELECT * FROM create_vlabel('PeopleGraph', 'People');
NOTICE: VLabel "People" has been created
create_vlabel
---------------
(1 row)
-- Alter the "People" label to "Actors".
ALTER TABLE "PeopleGraph"."People" RENAME TO "Actors";
ALTER TABLE
SELECT * FROM "PeopleGraph"."Actors";
id | properties
----+------------
(0 rows)
ALTER TABLE "PeopleGraph"."People_id_seq" RENAME TO "Actors_id_seq";
ALTER TABLE
SELECT * FROM "PeopleGraph"."Actors_id_seq" ;
last_value | log_cnt | is_called
------------+---------+-----------
1 | 0 | f
(1 row)
```
Is there another way to do that in AGE? I was also thinking about creating a function just for that using SPI, but it would probably lack performance, and queries such as the one that is shown in Neo4j wouldn't be possible just with SPI, I guess. If this is something that would be interesting to add to AGE, which structures and/or functions should I study to create a function to rename labels?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@age.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [age] Amr-Shams commented on issue #1254: Renaming a Label
Posted by "Amr-Shams (via GitHub)" <gi...@apache.org>.
Amr-Shams commented on issue #1254:
URL: https://github.com/apache/age/issues/1254#issuecomment-1740051425
I could think of a similar function that does the above.
I believe the sequence of actions taken in the preceding function refers to the following actions
```
CREATE OR REPLACE FUNCTION age_rename_label(
graph_name text,
old_label text,
new_label text)
RETURNS void
AS $$
BEGIN
-- Update label name in age metadata tables
UPDATE age_graph_labels
SET label = new_label
WHERE graph = graph_name AND label = old_label;
-- Update label name in vertex tables
EXECUTE format('ALTER TABLE %I.%I RENAME TO %I', graph_name, old_label, new_label);
-- Update label name in edge tables
EXECUTE format('ALTER TABLE %I.edge_of_%I RENAME TO edge_of_%I', graph_name, old_label, new_label);
-- Rename related sequences
EXECUTE format('ALTER TABLE %I.%I_id_seq RENAME TO %I_id_seq', graph_name, old_label, new_label);
EXECUTE format('ALTER TABLE %I.edge_of_%I_id_seq RENAME TO edge_of_%I_id_seq', graph_name, old_label, new_label);
END;
$$ LANGUAGE plpgsql;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@age.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Renaming a Label [age]
Posted by "rafsun42 (via GitHub)" <gi...@apache.org>.
rafsun42 commented on issue #1254:
URL: https://github.com/apache/age/issues/1254#issuecomment-1747781533
Hi @MatheusFarias03. We are planning to add support for label rename as a part of the label redesign project.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@age.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [age] Amr-Shams commented on issue #1254: Renaming a Label
Posted by "Amr-Shams (via GitHub)" <gi...@apache.org>.
Amr-Shams commented on issue #1254:
URL: https://github.com/apache/age/issues/1254#issuecomment-1740052074
when I Looked in Neoj4 they do have a full utility that does the renaming of the node
from the name to the property of the node.
I think this will be a valuable addition.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@age.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Renaming a Label [age]
Posted by "rafsun42 (via GitHub)" <gi...@apache.org>.
rafsun42 closed issue #1254: Renaming a Label
URL: https://github.com/apache/age/issues/1254
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@age.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org