Token Functions in WHERE Clause

The token functions in this section can only be used in the WHERE clause of a LOAD statement.

Besides the functions in the following table, all token functions for attribute expressions can also be used in the WHERE clause, including user-defined functions.
Function name Output type Description of function

to_int( main_string )

INT

Converts main_string to an integer value.

to_float( main_string )

FLOAT

Converts main_string to a float value.

concat( string1, string2 )

STRING

Returns a string which is the concatenation of string1 and string2 .

token_len( main_string )

INT

Returns the length of main_string.

gsql_is_not_empty_string( main_string )

BOOL

Returns true if main_string is empty after removing white space. Returns false otherwise.

gsql_token_equal( string1, string2 )

BOOL

Returns true if string1 is exactly the same (case-sensitive) as string2 . Returns false otherwise.

gsql_token_ignore_case_equal( string1, string2 )

BOOL

Returns true if string1 is exactly the same (case-insensitive) as string2. Returns false otherwise.

gsql_is_true( main_string )

BOOL

Returns true if main_string is either "t" or "true" (case-insensitive). Returns false otherwise.

gsql_is_false( main_string )

BOOL

Returns true if main_string is either "f" or "false" (case-insensitive). Returns false otherwise.

Examples

Single token function

These functions can be used as part of expression in the WHERE clause. For example, the following statement only loads a record if the score column of a record is greater than 95.5:

LOAD f TO VERTEX Person
  VALUES ($"name", $"score")
  WHERE to_float($"score") > 95.5

Token functions with logical operators

You can use logical operators such as AND, OR, NOT,IN, IS NUMERIC, IS EMPTY, and BETWEEN …​ AND in the WHERE clause with token functions.

CREATE LOADING JOB load_token FOR GRAPH Example_Graph {
    LOAD "data/data.csv"
    TO VERTEX vertex_1 VALUES($0, $1, $2, $3, $4, $5)
    WHERE gsql_token_equal($1,"DHB09")
      OR  token_len($2) > 15
      AND gsql_substr($2, 0, 3) == “DHB”
      OR  to_int($2)  IN (1,10)
      OR  to_float($5) BETWEEN 1 AND 100.5
      AND $4 == “12”
    USING SEPARATOR=",", HEADER="true", EOL="\n";
}