YMatrix
Quick Start
Connecting
Benchmarks
Deployment
Data Usage
Manage Clusters
Upgrade
Global Maintenance
Expansion
Monitoring
Security
Best Practice
Technical Principles
Data Type
Storage Engine
Execution Engine
Streaming Engine(Domino)
MARS3 Index
Extension
Advanced Features
Advanced Query
Federal Query
Grafana
Backup and Restore
Disaster Recovery
Graph Database
Introduction
Clauses
Functions
Advanced
Guide
Performance Tuning
Troubleshooting
Tools
Configuration Parameters
SQL Reference
The SET clause updates labels and properties on vertices and edges.
Note!
In YMatrix AGE, the underlying MPP storage requires data motion, which partitions the query into multiple slices. Because YMatrix permits only one write slice per transaction, using multiple write operators in a single Cypher statement may trigger:
ERROR: AssignTransactionId() called by Segment Reader process.
Therefore, minimize concurrent use of multiple write operators (e.g.,CREATE,SET,REMOVE,MERGE) within a single Cypher statement.
A SET clause not followed by another clause is terminal. When a Cypher query ends with a terminal clause, the cypher() function returns no result rows. However, the cypher() function still requires a column definition list. When the query ends in a terminal clause, define a dummy column in the list — the variable yields no data.
To set a property on a vertex or edge, use SET.
SELECT *
FROM cypher('graph_name', $$
MATCH (v {name: 'Andres'})
SET v.surname = 'Taylor'
$$) AS (v agtype);
The query applies the change but returns no rows.
| v |
|---|
| (0 rows) |
Use the following query to update and return a single vertex:
SELECT *
FROM cypher('graph_name', $$
MATCH (v {name: 'Andres'})
SET v.surname = 'Taylor'
RETURN v
$$) AS (v agtype);
Returns the updated vertex.
| v |
|---|
{id: 3; label: 'Person'; properties: {surname: "Taylor", name: "Andres", age: 36, hungry: true}}::vertex |
| (1 row) |
Although REMOVE is the standard way to delete a property, SET can also be used — for example, when the property value originates from a parameter.
SELECT *
FROM cypher('graph_name', $$
MATCH (v {name: 'Andres'})
SET v.name = NULL
RETURN v
$$) AS (v agtype);
Returns the vertex with the name property removed.
| v |
|---|
{id: 3; label: 'Person'; properties: {surname: "Taylor", age: 36, hungry: true}}::vertex |
| (1 row) |
To set multiple properties in one query, separate assignments with commas.
SELECT *
FROM cypher('graph_name', $$
MATCH (v {name: 'Andres'})
SET v.position = 'Developer', v.surname = 'Taylor'
RETURN v
$$) AS (v agtype);
| v |
|---|
{"id": 281474976710661, "label": "", "properties": {"name": "Andres", "surname": "Taylor", "position": "Developer"}}::vertex |
| (1 row) |
Multiple SET clauses may also be used to assign properties.
Prefer setting multiple properties in a single
SETclause rather than splitting them across multipleSETclauses.
SELECT *
FROM cypher('graph_name', $$
MATCH (v {name: 'Andres'})
SET v.position = 'Developer'
SET v.surname = 'Taylor'
RETURN v
$$) AS (v agtype);
| v |
|---|
{"id": 281474976710661, "label": "", "properties": {"name": "Andres", "surname": "Taylor", "position": "Developer"}}::vertex |
| (1 row) |