The documentation does not mention much about it. I was working on a blog post where I need to rename a property to something else. Does Apache AGE support renaming properties? There is no information on the page of SET clause either here.
Hey you can achieve that through using two consecutive operations [SET with the new property name then REMOVE the old property name]
Example:
1- Query the existing data (vid is the property which will be changed)
SELECT *
FROM cypher('test', $$
MATCH (a:Person{vid:1}) return a
$$) as (e agtype);
e
--------------------------------------------------------------------------------------------------
{"id": 844424930131972, "label": "Person", "properties": {"vid": 1, "title": "backend"}}::vertex
(1 row)
2- SET THEN REMOVE
SELECT *
FROM cypher('test', $$
MATCH (a:Person{vid:1}) set a.vcid = a.vid remove a.vid
$$) as (e agtype);
e
---
(0 rows)
3- Test old query to check if vid still existing or not
SELECT *
FROM cypher('test', $$
MATCH (a:Person{vid:1}) return a
$$) as (e agtype);
e
---
(0 rows)
4- Test the new changed property
SELECT *
FROM cypher('test', $$
MATCH (a:Person{vcid:1}) return a
$$) as (e agtype);
e
---------------------------------------------------------------------------------------------------
{"id": 844424930131972, "label": "Person", "properties": {"vcid": 1, "title": "backend"}}::vertex
(1 row)