Token Functions

The token functions in this section are used in the attribute expressions in the destination clause or as part of a condition in the WHERE clause of a LOAD statement.

Function Output type Description

gsql_reverse(in_string)

STRING

Returns a string with the characters in the reverse order of the input string in_string.

gsql_concat(string1, string2,…​,stringN)

STRING

Returns a string which is the concatenation of all the input strings.

gsql_uuid_v4()

STRING

Returns a version-4 UUID.

gsql_split_by_space(in_string)

STRING

Returns a modified version of in_string, in which each space character is replaced with ASCII 30 (decimal).

gsql_substring(_str_, _beginIndex_ [, _length_])

STRING

Returns the substring beginning at beginIndex, having the given length.

gsql_find(str, substr)

INT

Returns the start index of the substring within the string. If it is not found, then return -1.

gsql_length(str)

INT

Returns the length of the string.

gsql_replace(_str_, _oldToken_, _newToken_ [, _max_])

STRING

Returns the string resulting from replacing all matching substrings of oldToken with newToken in the original string. If a max count is provided, there can only be up to that many replacements.

gsql_regex_replace(str, regex, replaceSubstr)

STRING

Returns the string resulting from replacing all substrings in the input string that match the given regex token with the substitute string.

gsql_regex_match(str, regex)

bool

Returns true if the given string token matches the given regex token and false otherwise.

gsql_to_bool(in_string)

bool

Returns true if the in_string is either "t" or "true", with case-insensitive checking. Returns false otherwise.

gsql_to_uint(in_string)

UINT

  • If in_string is the string representation of an unsigned integer, the function returns that integer.

  • If in_string is the string representation of a non-negative float, the function returns that number cast as an integer.

gsql_to_int(in_string)

INT

  • If in_string is the string representation of an integer, the function returns that integer.

  • If in_string is the string representation of a float, the function returns that number cast as an integer.

gsql_ts_to_epoch_seconds(timestamp)

UINT

Converts a timestamp in canonical string format to Unix epoch time, which is the int number of seconds since Jan. 1, 1970. Refer to the timestamp input format note below.

gsql_current_time_epoch(0)

UINT

Returns the current time in Unix epoch seconds. By convention, the input parameter should be 0, but it is ignored.

Splits a multi-value field into a set of records. Those records are first stored in a temporary table, and then the temporary table can be loaded into vertices and/or edges.

Parses a JSON array of primitive values or JSON objects, as well as JSON objects in a column of a CSV file.

Reads a compound token and splits it into a collection of elements, to form a set or list collection, or a map.

gsql_upper(in_string)

STRING

Returns the input string in upper-case.

gsql_lower(in_string)

STRING

Returns the input string in lower-case.

gsql_trim(in_string)

STRING

Trims whitespace from the beginning and end of the input string.

STRING

Trims white space from either the beginning or the end of the input string (Left or right).

gsql_year(timestamp)

INT

Returns 4-digit year from timestamp.

gsql_month(timestamp)

INT

Returns month (1-12) from timestamp.

gsql_day(timestamp)

INT

Returns day (1-31) from timestamp.

gsql_year_epoch(epoch)

INT

Returns 4-digit year from Unix epoch time, which is the number of seconds since Jan. 1, 1970.

gsql_month_epoch(epoch)

INT

Returns month (1-12) from Unix epoch time, which is the number of seconds since Jan. 1, 1970.

gsql_day_epoch(epoch)

INT

Returns day (1-31) from Unix epoch time, which is the number of seconds since Jan. 1, 1970.