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.

ascii(in_string)

INT

Returns the ASCII (numeric) position of the first character in a string. If the argument is an empty string, returns 0.

chr(n)

STRING

Converts an integer to a character according to its ASCII position. If the input value n is greater than 255, returns the character at the position of the modulo of n / 256.

difference(str1, str2)

INT

Compares the Soundex codes of two strings and returns an integer from 0 to 4 indicating the similarity between the input strings' phonetic representation values.

find_in_set(str, str_list)

INT

Returns the position of a string within a list of strings separated by commas.

insert(str1, position[, number, str2)]

STRING

Inserts a string within a string at the specified position and for a certain number of characters, and replaces a specified number of characters starting from the insertion position.

instr (str, substr [, position, occurrence)]

INT

Searches a string str for a substring substr and returns the position of the first character of the substring.

left(str, number_of_chars)

STRING

Extracts a number of characters from a string starting from position 0 and capturing left to right.

right(str, number_of_chars)

STRING

Extracts a number of characters from a string starting from the last character and capturing right to left.

lpad(str, padded_length [, pad_str)]

STRING

Pads the left side of a string with another pad string. If the pad string pad_str is omitted, it will pad with white space.

rpad(str, padded_length [, pad_str)]

STRING

Pads the right side of a string (str) with another pad string. If the pad string (pad_str) is omitted, it will pad with white space.

soundex(str)

STRING

Returns a character string containing the Soundex code of str.

space(n)

STRING

Returns a string that contains the specified number of space characters.

translate(str_origin, characters, translations)

STRING

Replaces specified characters in a string with a different set of specified characters.