String functions
Functions for manipulating text values.LOWER
Converts a string to lowercase. Syntax:LOWER(string)
Example:
UPPER
Converts a string to uppercase. Syntax:UPPER(string)
Example:
TRIM
Removes leading and trailing whitespace. Syntax:TRIM(string)
Example:
LTRIM / RTRIM
Removes leading (LTRIM) or trailing (RTRIM) whitespace. Syntax:LTRIM(string), RTRIM(string)
SUBSTRING
Extracts a portion of a string. Syntax:SUBSTRING(string, start, length)
start: 1-based starting positionlength: number of characters to extract
CONCAT
Concatenates multiple strings. Syntax:CONCAT(string1, string2, ...)
Example:
LENGTH
Returns the length of a string. Syntax:LENGTH(string)
Example:
REPLACE
Replaces occurrences of a substring. Syntax:REPLACE(string, search, replacement)
Example:
SPLIT
Splits a string into an array by delimiter. Syntax:SPLIT(string, delimiter)
Example:
SPLIT_PART
Extracts a specific part from a delimited string. Syntax:SPLIT_PART(string, delimiter, index)
index: 1-based position of the part to extract
POSITION
Returns the position of a substring (1-based), or 0 if not found. Syntax:POSITION(substring IN string)
Example:
REGEXP_REPLACE
Replaces text matching a regular expression. Syntax:REGEXP_REPLACE(string, pattern, replacement)
Example:
REGEXP_EXTRACT
Extracts text matching a regular expression. Syntax:REGEXP_EXTRACT(string, pattern)
Example:
Date and time functions
Functions for working with dates and timestamps.TO_TIMESTAMP
Parses a string into a timestamp. Syntax:TO_TIMESTAMP(string, format)
Common format patterns:
| Pattern | Description | Example |
|---|---|---|
YYYY | 4-digit year | 2024 |
MM | 2-digit month | 01-12 |
DD | 2-digit day | 01-31 |
HH24 | 24-hour hour | 00-23 |
HH12 | 12-hour hour | 01-12 |
MI | Minutes | 00-59 |
SS | Seconds | 00-59 |
AM/PM | AM/PM indicator | AM, PM |
TRY_TO_TIMESTAMP
Like TO_TIMESTAMP, but returns NULL instead of error on parse failure. Syntax:TRY_TO_TIMESTAMP(string, format)
Example:
TO_DATE
Parses a string into a date (without time component). Syntax:TO_DATE(string, format)
Example:
CURRENT_TIMESTAMP
Returns the current timestamp in UTC. Syntax:CURRENT_TIMESTAMP
CURRENT_DATE
Returns the current date. Syntax:CURRENT_DATE
DATE_DIFF
Calculates the difference between two dates. Syntax:DATE_DIFF(unit, start, end)
Units: 'year', 'month', 'day', 'hour', 'minute', 'second'
Example:
DATE_ADD / DATE_SUB
Adds or subtracts an interval from a date. Syntax:DATE_ADD(date, interval), DATE_SUB(date, interval)
Example:
YEAR / MONTH / DAY
Extracts components from a date or timestamp. Syntax:YEAR(date), MONTH(date), DAY(date)
Example:
HOUR / MINUTE / SECOND
Extracts time components from a timestamp. Syntax:HOUR(timestamp), MINUTE(timestamp), SECOND(timestamp)
Type conversion functions
Functions for converting between data types.CAST
Converts a value to a specified type. Syntax:CAST(expression AS type)
Supported types: INTEGER, BIGINT, FLOAT, DOUBLE, VARCHAR, BOOLEAN, TIMESTAMP, DATE
Examples:
TRY_CAST
Like CAST, but returns NULL instead of error on conversion failure. Syntax:TRY_CAST(expression AS type)
Example:
Conditional functions
Functions for conditional logic.CASE
Evaluates conditions and returns a result. Simple CASE syntax:COALESCE
Returns the first non-null argument. Syntax:COALESCE(expr1, expr2, ...)
Example:
NULLIF
Returns NULL if two expressions are equal, otherwise returns the first expression. Syntax:NULLIF(expr1, expr2)
Example:
IF
Simple conditional expression (shorthand for CASE). Syntax:IF(condition, true_result, false_result)
Example:
Null handling functions
Functions for working with NULL values.COALESCE
(See Conditional functions above)NULLIF
(See Conditional functions above)IFNULL
Returns the second argument if the first is NULL. Syntax:IFNULL(expr, default_value)
Example:
IS NULL / IS NOT NULL
Tests for NULL values. Example:Array functions
Functions for working with arrays.ARRAY
Creates an array from values. Syntax:ARRAY(value1, value2, ...)
Example:
ARRAY_CONTAINS
Checks if an array contains a value. Syntax:ARRAY_CONTAINS(array, value)
Example:
TRANSFORM
Applies a function to each array element. Syntax:TRANSFORM(array, element -> expression)
Example:
FILTER
Filters array elements based on a condition. Syntax:FILTER(array, element -> condition)
Example:
ARRAY_JOIN
Joins array elements into a string. Syntax:ARRAY_JOIN(array, delimiter)
Example:
Struct functions
Functions for working with structs.STRUCT
Creates a struct from named values. Syntax:STRUCT(expr1 AS name1, expr2 AS name2, ...)
Example:
Accessing struct fields
Use dot notation to access struct fields. Example:JSON functions
Functions for parsing and working with JSON data.JSON_PARSE
Parses a JSON string into a structured value. Syntax:JSON_PARSE(json_string)
Example:
JSON_EXTRACT
Extracts a value from JSON using a path. Syntax:JSON_EXTRACT(json, path)
Example:
JSON_EXTRACT_SCALAR
Extracts a scalar value from JSON. Syntax:JSON_EXTRACT_SCALAR(json, path)
Example:
Hash functions
Functions for hashing values.SHA256
Computes SHA-256 hash. Syntax:SHA256(string)
Returns: 64-character hexadecimal string
Example:
MD5
Computes MD5 hash. Syntax:MD5(string)
Returns: 32-character hexadecimal string
Mathematical functions
Functions for numeric operations.ABS
Returns absolute value. Syntax:ABS(number)
ROUND
Rounds to specified decimal places. Syntax:ROUND(number, decimals)
Example:
FLOOR / CEIL
Rounds down (FLOOR) or up (CEIL) to nearest integer. Syntax:FLOOR(number), CEIL(number)
MOD
Returns remainder of division. Syntax:MOD(dividend, divisor)

