---
title: "Token Functions"
description: "Overview of token functions."
component: "gsql-ref"
version: "4.2"
module: "ddl-and-loading"
html_url: "/gsql-ref/4.2/ddl-and-loading/functions/token/"
canonical_url: "https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/"
markdown_url: "https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/index.md"
---

[View as HTML](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/)

# 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](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token_where/index.md#_token_functions_with_logical_operators).

| Function | Output type | Description |
| --- | --- | --- |
| [gsql\_reverse(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_reverse.md) | `STRING` | Returns a string with the characters in the reverse order of the input string _in\_string_. |
| [gsql\_concat(_string1, string2,…​,stringN_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_concat.md) | `STRING` | Returns a string which is the concatenation of all the input strings. |
| [gsql\_uuid\_v4()](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_uuid_v4.md) | `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\_\])](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_substring.md) | `STRING` | Returns the substring beginning at _beginIndex_, having the given _length_. |
| [gsql\_find(_str_, _substr_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_find.md) | `INT` | Returns the start index of the substring within the string. If it is not found, then return -1. |
| [gsql\_length(_str_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_length.md) | `INT` | Returns the length of the string. |
| [gsql\_replace(\_str\_, \_oldToken\_, \_newToken\_ \[, \_max\_\])](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_replace.md) | `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_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_regex_replace.md) | `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_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_regex_match.md) | `BOOL` | Returns true if the given string token matches the given regex token and false otherwise. |
| [gsql\_to\_bool(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_to_bool.md) | `BOOL` | Returns true if the _in\_string_ is either "t" or "true", with case-insensitive checking. Returns false otherwise. |
| [gsql\_to\_uint(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_to_uint.md) | `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_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_to_int.md) | `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_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_ts_to_epoch.md) | `UINT` | Converts a timestamp in canonical string format to Unix epoch time, which is the int number of seconds since Jan. 1, 1970. |
| [gsql\_ts\_to\_epoch\_seconds\_legacy(timestamp, defaultTimestamp = 0)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_ts_to_epoch_legacy.md) | `uint64_t` | Converts a timestamp to Unix epoch time. Returns a default value (`0` or user-specfied) for timestamps before 1970. |
| [gsql\_ts\_to\_epoch\_seconds\_signed(timestamp, defaultTimestamp = 0)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_ts_to_epoch_signed.md) | `int64_t` | Converts a timestamp to Unix epoch time. Supports a wider range of dates, including pre-1970, and returns negative values for those dates. |
| [gsql\_current\_time\_epoch(0)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_current_time_epoch.md) | `UINT` | Returns the current time in Unix epoch seconds. By convention, the input parameter should be 0, but it is ignored. |
| [flatten (_column\_to\_be\_split, group\_separator, 1_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/flatten.md) [flatten (_column\_to\_be\_split, group\_separator, sub\_field\_separator, number\_of\_sub\_fields\_in\_one\_group_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/flatten.md) |  | 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. |
| [flatten\_json\_array (_$"array\_name"_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/flatten_json_array.md) [flatten\_json\_array (_$"array\_name", $"sub\_obj\_1", $"sub\_obj\_2", …​, $"sub\_obj\_n"_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/flatten_json_array.md) |  | Parses a JSON array of primitive values or JSON objects, as well as JSON objects in a column of a CSV file. |
| [split(_column\_to\_be\_split, element\_separator_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/split.md) [split(_column\_to\_be\_split, key\_value\_separator, element \_separator_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/split.md) |  | 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_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_upper.md) | `STRING` | Returns the input string in upper-case. |
| [gsql\_lower(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_lower.md) | `STRING` | Returns the input string in lower-case. |
| [gsql\_trim(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_trim.md) | `STRING` | Trims whitespace from the beginning and end of the input string. |
| [gsql\_ltrim(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_ltrim.md) [gsql\_rtrim(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_rtrim.md) | `STRING` | Trims white space from either the beginning or the end of the input string (Left or right). |
| [gsql\_year(_timestamp_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_year.md) | `INT` | Returns 4-digit year from timestamp. |
| [gsql\_month(timestamp)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_month.md) | `INT` | Returns month (1-12) from timestamp. |
| [gsql\_day(_timestamp_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_day.md) | `INT` | Returns day (1-31) from timestamp. |
| [gsql\_year\_epoch(_epoch_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_year_epoch.md) | `INT` | Returns 4-digit year from Unix epoch time, which is the number of seconds since Jan. 1, 1970. |
| [gsql\_month\_epoch(_epoch_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_month_epoch.md) | `INT` | Returns month (1-12) from Unix epoch time, which is the number of seconds since Jan. 1, 1970. |
| [gsql\_day\_epoch(_epoch_)](https://www.tigergraph.com/docs/gsql-ref/4.2/ddl-and-loading/functions/token/gsql_day_epoch.md) | `INT` | Returns day (1-31) from Unix epoch time, which is the number of seconds since Jan. 1, 1970. |
| [ascii(_in\_string_)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#ascii) | `INT` | Returns the ASCII (numeric) position of the first character in a string. If the argument is an empty string, returns `0`. |
| [chr(_n_)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#chr) | `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_)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#difference) | `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_)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#find_in_set) | `INT` | Returns the position of a string within a list of strings separated by commas. |
| [insert(_str1_, _position_\[, _number_](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#insert), _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_](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#instr))\] | `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)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#left) | `STRING` | Extracts a number of characters from a string starting from position 0 and capturing left to right. |
| [right(str, number\_of\_chars)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#right) | `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](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#lpad))\] | `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](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#rpad))\] | `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)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#_soundex) | `STRING` | Returns a character string containing the Soundex code of str. |
| [space(_n_)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#space) | `STRING` | Returns a string that contains the specified number of space characters. |
| [translate(str\_origin, characters, translations)](https://www.tigergraph.com/docs/gsql-ref/4.2/querying/func/string-functions.md#translate) | `STRING` | Replaces specified characters in a string with a different set of specified characters. |
