CREATE
CREATE (a:Person {name: 'Alice', age: 30})-[:KNOWS]->(b:Person {name: 'Bob', age: 25})Create nodes and relationships in one statement. Returns nothing unless you add RETURN.
Syntax#
CREATE (variable:Label {key: value, ...}) [RETURN variable]
CREATE (a:Label {props})-[:TYPE]->(b:Label {props})DDL forms — declare label schemas:
CREATE NODE LABEL Label (
col TYPE, ...
)
[VIRTUAL FROM PARTITION '<lake-uri-pattern>']
[COMPUTE
derived_col = <expr>,
...
];Examples#
Create a node#
CREATE (n:Person {name: 'Eve', age: 28}) RETURN nDeclare a virtual label over a Lakehouse partition#
CREATE NODE LABEL Frame (
agent_id STRING,
ts TIMESTAMP,
agent_position DOUBLE[3]
) VIRTUAL FROM PARTITION 'lake://fleet/telemetry/{mission}/{day}/{shard}';Rows stay in the parquet partitions; the engine holds the typed schema
- adjacency + catalog pointer. See the virtual labels cookbook for the full walkthrough.
Declare derived properties with COMPUTE#
CREATE NODE LABEL FrameRelToTarget VIRTUAL FROM PARTITION
'lake://fleet/telemetry/{mission}/{day}/{shard}'
COMPUTE
position_relative_to_target = agent_position - target_position,
distance_to_target = sqrt(
(agent_position[0] - target_position[0]) ^ 2 +
(agent_position[1] - target_position[1]) ^ 2 +
(agent_position[2] - target_position[2]) ^ 2
);COMPUTE columns are evaluated by the Smart Reader at row-decode time
against the decoded RecordBatch. The values surface in
Node.properties alongside parquet-resident columns; predicates on
them push down through the planner. Row data on disk is unchanged —
the derived properties exist only as values flowing through the scan.
See virtual computed columns
for the full surface.
Notes#
- Node IDs are engine-assigned (monotonic
NodeId). - Properties are set at creation time. Use SET for mutations.
- For upsert semantics (find-or-create), use MERGE.
VIRTUAL FROM PARTITIONandCOMPUTEare DDL-only modifiers onCREATE NODE LABEL— they declare a class, they don't create individual nodes. Once registered,MATCH (:Frame)traverses the rows in the bound partitions.
See Also#
- MERGE — upsert
- DELETE — removal
- SET — property mutation
- Virtual computed columns —
the
COMPUTEclause in depth - World Store layer — the
substrate the
VIRTUAL FROM PARTITIONclause binds against
Try it
Open ↗⌘↵ to run
Loading engine…