split()
The SPLIT() function reads a compound token and splits it into a collection of elements, to form a set or list collection, or a map.
Parameters
The function can split a column to load to a map attribute or a set/list attribute.
When it loads data to a set/list attribute:
- column
-
Required. The index or the name of the column to split.
- separator
-
Required. The separator by which to split the values in the column.
When it loads data into a map attribute:
- column
-
Required. The index or the name of the column to split.
- separator
-
Required. The separator that splits the key-value pairs in the column. For example. if the key-value pair in the column is formatted like this:
key:value
, then the separator is:
. - sub_separator
-
Required only when the column has multiple key-value pairs separated by a sub separator. For example, if the column has values such as
key1:value1,key2:value2
, thensub_separator
is,
.
Examples
Load a MAP
attribute
vid,key_value
v1,1:mike
v2,2:tom
v1,3:lucy
vid,key_value_list
v1,1:mike#4:lin
v2,2:tom
v1,3:lucy#1:john#6:jack
CREATE VERTEX v_map (PRIMARY_ID id STRING, att_map MAP<INT, STRING>)
CREATE GRAPH Test_Graph (*)
CREATE LOADING JOB load_map FOR GRAPH Test_Graph {
DEFINE FILENAME f;
LOAD f TO VERTEX v_map VALUES ($0, SPLIT($1, ":", "#"));
}