Chalk SQL Reference

This reference documents the complete set of Chalk SQL functions for federated queries across data sources, offline stores, and the Chalk catalog.

Returns the absolute value of a number.
Examples
SELECT abs(-42);
| abs(-42) |
| -------- |
| 42       |
Overloads
Calculates the inverse cosine in radians.
Parameters
x:
double
The input value.
Calculates the inverse hyperbolic cosine.
Parameters
x:
double
The input value.
Calculates the inverse hyperbolic sine.
Parameters
x:
double
The input value.
Calculates the inverse hyperbolic tangent.
Parameters
x:
double
The input value.
Calculates the inverse sine in radians.
Parameters
x:
double
The input value.
Calculates the arctangent of a number in radians.
Parameters
x:
double
The input value.
Calculates the arctangent of y/x in radians, handling quadrant correctly.
Parameters
y:
double
The second input value.
x:
double
The input value.
Rounds a number using banker's rounding, optionally to a specified number of decimal places.
Examples
SELECT bankers_round(2.5);
| bankers_round(2.5) |
| ------------------ |
| 2.0                |
SELECT bankers_round(42.125, 2);
| bankers_round(42.125, 2) |
| ------------------------ |
| 42.12                    |
Calculates the cube root of a number.
Examples
SELECT cbrt(27);
| cbrt(27) |
| -------- |
| 3.0      |
Overloads
Alias for ceiling.
Examples
SELECT ceil(42.1);
| ceil(42.1) |
| ---------- |
| 43.0       |
Returns the smallest integer greater than or equal to the given number.
Examples
SELECT ceiling(42.1);
| ceiling(42.1) |
| ------------- |
| 43.0          |
Constrains a value to a minimum and maximum range.
Examples
SELECT clamp(12, 0, 10);
| clamp(12, 0, 10) |
| ---------------- |
| 10               |
Calculates the cosine of an angle in radians.
Parameters
x:
double
The input value.
Calculates the hyperbolic cosine of a number.
Parameters
x:
double
The input value.
Calculates the cotangent of an angle in radians.
Parameters
x:
double
The input value.
Converts radians to degrees.
Parameters
radians:
double
The angle in radians.
Examples
SELECT degrees(pi());
| degrees(pi()) |
| ------------- |
| 180.0         |
Returns the mathematical constant e (Euler's number).
Parameters
None
Calculates e raised to the power of a number.
Parameters
x:
double
The input value.
Returns the largest integer less than or equal to the given number.
Examples
SELECT floor(42.9);
| floor(42.9) |
| ----------- |
| 42.0        |
Checks if a floating-point number is finite (not NaN or infinite).
Parameters
value:
double
The input value.
Checks if a floating-point number is infinite.
Parameters
value:
double
The input value.
Checks if a floating-point number is NaN (Not a Number).
Parameters
value:
double
The input value.
Calculates the natural logarithm of a number.
Parameters
x:
double
The input value.
Calculates the logarithm of a number with a specified or default base.
Examples
SELECT log(10, 100);
| log(10, 100) |
| ------------ |
| 2.0          |
Overloads
Calculates the base-10 logarithm of a number.
Parameters
x:
double
The input value.
Calculates the natural logarithm of (1 + x), accurate for small x.
Parameters
x:
double
The input value.
Calculates the base-2 logarithm of a number.
Parameters
x:
double
The input value.
Returns a floating point NaN (Not a Number) value.
Parameters
None
Returns the negative value of a number.
Returns the mathematical constant π (pi).
Parameters
None
Raises a number to the power of another number.
Parameters
base:
double
The base value.
exponent:
double
The exponent to raise the base to.
Examples
SELECT pow(2.0, 8.0);
| pow(2.0, 8.0) |
| ------------- |
| 256.0         |
Raises the first number to the power of the second number.
Parameters
base:
double
The base value.
exponent:
double
The exponent to raise the base to.
Examples
SELECT power(2.0, 8.0);
| power(2.0, 8.0) |
| --------------- |
| 256.0           |
Converts degrees to radians.
Parameters
degrees:
double
The angle in degrees.
Examples
SELECT radians(180.0);
| radians(180.0)    |
| ----------------- |
| 3.141592653589793 |
Generates a random float between 0 and 1.
Parameters
None
Generates a pseudo-random float or integer.
Examples
SELECT random();
| random()                  |
| ------------------------- |
| <random double in [0, 1)> |
Rounds a floating point number, optionally to a specified number of decimal places.
Examples
SELECT round(42.5);
| round(42.5) |
| ----------- |
| 43.0        |
SELECT round(42.125, 2);
| round(42.125, 2) |
| ---------------- |
| 42.13            |
Rounds a number to n significant figures.
Parameters
value:
double
The input value.
digits:
int64
The number of significant digits to keep.
Returns the sign of a number as -1, 0, or 1.
Examples
SELECT sign(-42);
| sign(-42) |
| --------- |
| -1        |
Overloads
Calculates the sine of an angle in radians.
Parameters
x:
double
The input value.
Calculates the square root of a number.
Parameters
x:
double
The input value.
Examples
SELECT sqrt(144.0);
| sqrt(144.0) |
| ----------- |
| 12.0        |
Calculates the tangent of an angle in radians.
Parameters
x:
double
The input value.
Calculates the hyperbolic tangent of a number.
Parameters
x:
double
The input value.
Truncates a floating-point number, optionally to a specified number of decimal places.
Examples
SELECT truncate(42.987);
| truncate(42.987) |
| ---------------- |
| 42.0             |
SELECT truncate(42.987, 2);
| truncate(42.987, 2) |
| ------------------- |
| 42.98               |
Returns the remainder after dividing the first value by the second.
Examples
SELECT 7 % 3;
| 7 % 3 |
| ----- |
| 1     |
Overloads
Multiplies numeric values, or scales a duration by a numeric value.
Examples
SELECT 6 * 7;
| 6 * 7 |
| ----- |
| 42    |
basic binary ** operation
Parameters
x:
double
The input value.
y:
double
The second input value.
Adds numeric, temporal, or interval values.
Examples
SELECT 2 + 3;
| 2 + 3 |
| ----- |
| 5     |
Subtracts numeric, temporal, or interval values.
Examples
SELECT 7 - 3;
| 7 - 3 |
| ----- |
| 4     |
Negates a numeric value.
Examples
SELECT -42;
| -42 |
| --- |
| -42 |
Overloads
Divides numeric values, or divides a duration by a numeric value.
Examples
SELECT 7.0 / 2.0;
| 7.0 / 2.0 |
| --------- |
| 3.5       |
Overloads
floor division
Overloads
Alias for pow.
Examples
SELECT pow(2.0, 8.0);
| pow(2.0, 8.0) |
| ------------- |
| 256.0         |
Performs logical AND operation on two boolean values.
Parameters
x:
bool
The input value.
y:
bool
The second input value.
Checks if a value is between two bounds (inclusive).

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Parameters
value:
$T_ord
The input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
min:
$T_ord
The minimum bound, inclusive. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
max:
$T_ord
The maximum bound, inclusive. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
Returns the first non-null value from a list of arguments.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
The first value. T means matching inputs and outputs use the same type.
value2:
$T...
The second value. T means matching inputs and outputs use the same type.
Examples
SELECT coalesce(NULL, 'fallback');
| coalesce(NULL, 'fallback') |
| -------------------------- |
| fallback                   |
Checks if two values are distinct, treating NULL values as different from non-NULL values.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
x:
$T
The input value. T means matching inputs and outputs use the same type.
y:
$T
The second input value. T means matching inputs and outputs use the same type.
Returns whether two values are equal.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT eq(1, 1);
| eq(1, 1) |
| -------- |
| true     |
Returns whether the first value is greater than the second.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT gt(2, 1);
| gt(2, 1) |
| -------- |
| true     |
Returns whether the first value is greater than or equal to the second.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT gte(2, 2);
| gte(2, 2) |
| --------- |
| true      |
Returns the second argument if the condition is true, otherwise returns the third argument.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
The boolean condition to evaluate.
The value returned when the condition is true. T means matching inputs and outputs use the same type.
The value returned when the condition is false. T means matching inputs and outputs use the same type.
Checks if the input is null.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
The input value. T means matching inputs and outputs use the same type.
Returns whether the first value is less than the second.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT lt(1, 2);
| lt(1, 2) |
| -------- |
| true     |
Returns whether the first value is less than or equal to the second.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT lte(2, 2);
| lte(2, 2) |
| --------- |
| true      |
Returns whether two values are not equal.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT neq(1, 2);
| neq(1, 2) |
| --------- |
| true      |
Returns NULL if both arguments compare equal; otherwise returns the first argument.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
The first value. T means matching inputs and outputs use the same type.
The second value. T means matching inputs and outputs use the same type.
Checks if two values are equal, treating NULL values as equal to other NULL values.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
x:
$T
The input value. T means matching inputs and outputs use the same type.
y:
$T
The second input value. T means matching inputs and outputs use the same type.
Checks if two values are not equal, treating NULL values as different from non-NULL values.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
x:
$T
The input value. T means matching inputs and outputs use the same type.
y:
$T
The second input value. T means matching inputs and outputs use the same type.
basic binary != operation

Type parameters. T means matching inputs and outputs use the same type.

Parameters
x:
$T
The input value. T means matching inputs and outputs use the same type.
y:
$T
The second input value. T means matching inputs and outputs use the same type.
basic binary < operation

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Parameters
x:
$T_ord
The input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
y:
$T_ord
The second input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
basic binary <= operation

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Parameters
x:
$T_ord
The input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
y:
$T_ord
The second input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
basic binary == operation

Type parameters. T means matching inputs and outputs use the same type.

Parameters
x:
$T
The input value. T means matching inputs and outputs use the same type.
y:
$T
The second input value. T means matching inputs and outputs use the same type.
basic binary > operation

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Parameters
x:
$T_ord
The input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
y:
$T_ord
The second input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
basic binary >= operation

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Parameters
x:
$T_ord
The input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
y:
$T_ord
The second input value. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.
Counts the number of bits in `x`.
Parameters
x:
int64
The input value.
bits:
int64
The bit width to operate within.
Performs bitwise AND operation on two integer values.
Returns the arithmetic right shift operation on x in 2’s complement representation. shift must not be negative.
Parameters
x:
int64
The input value.
shift:
int64
Returns the logical right shift operation on x (treated as bits-bit integer) shifted by shift. shift must not be negative.
Parameters
x:
int64
The input value.
shift:
int64
bits:
int64
The bit width to operate within.
Performs bitwise NOT operation (complement) on an integer value.
Performs bitwise OR operation on two integer values.
Returns the left shift operation on x (treated as bits-bit integer) shifted by shift. shift must not be negative.
Parameters
x:
int64
The input value.
shift:
int64
bits:
int64
The bit width to operate within.
Performs bitwise XOR operation on two integer values.
Applies boolean AND or bitwise AND to two values.
Examples
SELECT TRUE & FALSE;
| TRUE & FALSE |
| ------------ |
| false        |
SELECT 6 & 3;
| 6 & 3 |
| ----- |
| 2     |
Overloads
Applies boolean OR or bitwise OR to two values.
Examples
SELECT TRUE | FALSE;
| TRUE \| FALSE |
| ------------- |
| true          |
SELECT 4 | 1;
| 4 \| 1 |
| ------ |
| 5      |
Overloads
Applies boolean NOT or bitwise NOT to a value.
Examples
SELECT ~TRUE;
| ~TRUE |
| ----- |
| false |
Overloads
~x
~x
~x
~x
~x
~x
Returns true if every element of the array satisfies the predicate.

Type parameters. T means matching inputs and outputs use the same type.

Returns true if any element of the array satisfies the predicate.

Type parameters. T means matching inputs and outputs use the same type.

Returns true if all elements in a boolean array are true.
Returns true if any element in a boolean array is true.
Adds an element to the end of an array.

Type parameters. T means matching inputs and outputs use the same type.

Returns the index of the maximum element in an array.
Returns the index of the minimum element in an array.
Calculates the average of numeric values in an array.
Removes all null values from an array.

Type parameters. T means matching inputs and outputs use the same type.

Creates an array from zero or more values.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_constructor(1, 2, 3);
| array_constructor(1, 2, 3) |
| -------------------------- |
| [1, 2, 3]                  |
Calculates the cumulative sum of numeric values in an array.
Returns an array with duplicate elements removed, preserving order.

Type parameters. T means matching inputs and outputs use the same type.

Returns an array containing only the duplicate elements from the input array.
Returns elements from the first array that are not present in the second array.

Type parameters. T means matching inputs and outputs use the same type.

Filters an array using a callback function predicate.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
predicate:
($T) => bool
T means matching inputs and outputs use the same type.
Returns a map of elements to their frequency counts in an array.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
Checks if an array contains duplicate elements.

Type parameters. T means matching inputs and outputs use the same type.

Returns the intersection of two arrays (elements present in both arrays).

Type parameters. T means matching inputs and outputs use the same type.

Joins array elements into a string using a separator and optional null replacement.

Type parameters. K is the key type of the input map.

Examples
SELECT array_join(array_constructor('a', 'b', 'c'), ',');
| array_join(array_constructor('a', 'b', 'c'), ',') |
| ------------------------------------------------- |
| a,b,c                                             |
Returns the maximum element in an array.

Type parameters. T means matching inputs and outputs use the same type.

Calculates the median value of numeric elements in an array.
Returns the minimum element in an array.

Type parameters. T means matching inputs and outputs use the same type.

Returns the 1-based position of an element in an array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT array_position(array_constructor('a', 'b', 'a'), 'a');
| array_position(array_constructor('a', 'b', 'a'), 'a') |
| ----------------------------------------------------- |
| 1                                                     |
Applies a reduce function to each element in an array and returns the accumulated value.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type. V is the value type of the input map.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
U is a second generic value type.
inputFunction:
($U, $T) => $U
T means matching inputs and outputs use the same type. U is a second generic value type.
outputFunction:
($U) => $V
V is the value type of the input map. U is a second generic value type.
Reduces an array with Python-style loop control. Lambda returns (new_state, control_code, result), where control_code is 0=normal, 1=return, 2=continue, 3=break. Returns row(final_state, control_code, result|null).

Type parameters. T means matching inputs and outputs use the same type. S is the callback state type. R is the callback result type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
The initial accumulator state. S is the callback state type.
function:
($S, $T) => struct<state: $S, control: int64, result: $R>
The callback function applied to the elements. T means matching inputs and outputs use the same type. R is the callback result type. S is the callback state type.
Removes all occurrences of a specified element from an array.

Type parameters. T means matching inputs and outputs use the same type.

Returns a slice from an array, string, or binary value.

Type parameters. E is the element type of the input array or list.

Examples
SELECT array_slice(array_constructor(1, 2, 3, 4), 2, 3);
| array_slice(array_constructor(1, 2, 3, 4), 2, 3) |
| ------------------------------------------------ |
| [2, 3, 4]                                        |
Sorts an array in ascending order, optionally using a key extraction function.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Examples
SELECT array_sort(array_constructor(3, 1, 2));
| array_sort(array_constructor(3, 1, 2)) |
| -------------------------------------- |
| [1, 2, 3]                              |
Sorts an array in descending order, optionally using a key extraction function.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Examples
SELECT array_sort_desc(array_constructor(3, 1, 2));
| array_sort_desc(array_constructor(3, 1, 2)) |
| ------------------------------------------- |
| [3, 2, 1]                                   |
Calculates the standard deviation of numeric values in an array.
Calculates the sum of numeric values in an array.
Applies a transformation function to each element in an array and returns a new array.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
function:
($T) => $U
The callback function applied to the elements. T means matching inputs and outputs use the same type. U is a second generic value type.
Checks if two arrays have any elements in common.

Type parameters. T means matching inputs and outputs use the same type.

Returns a list of the distinct elements of the common elements

Type parameters. T means matching inputs and outputs use the same type.

Returns the number of elements in an array or entries in a map.

Type parameters. V is the value type of the input map. K is the key type of the input map.

Examples
SELECT cardinality(array_constructor(1, 2, 3));
| cardinality(array_constructor(1, 2, 3)) |
| --------------------------------------- |
| 3                                       |
Returns all possible combinations of the given size from an array.

Type parameters. T means matching inputs and outputs use the same type.

Checks if a list contains a specific element.

Type parameters. V is the value type of the input map.

Parameters
array:
large_list<item: $V>
The input array or list. V is the value type of the input map.
The element to search for. V is the value type of the input map.
Returns an element from an array or map.

Type parameters. E is the element type of the input array or list. K is the key type of the input map. V is the value type of the input map.

Examples
SELECT element_at(array_constructor('a', 'b'), 2);
| element_at(array_constructor('a', 'b'), 2) |
| ------------------------------------------ |
| b                                          |
Returns the first element in an array that matches the given predicate function.

Type parameters. T means matching inputs and outputs use the same type.

Returns the 1-based index of the first element in an array that matches the given predicate function.

Type parameters. T means matching inputs and outputs use the same type.

Flattens a nested array by one level, combining all sub-arrays into a single array.

Type parameters. T means matching inputs and outputs use the same type.

Returns the largest value from a list of values.

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Examples
SELECT greatest(3.0, 7.0, 5.0);
| greatest(3.0, 7.0, 5.0) |
| ----------------------- |
| 7.0                     |
SELECT greatest(3, 7, 5);
| greatest(3, 7, 5) |
| ----------------- |
| 7                 |
Returns the smallest value from a list of values.

Type parameters. T_ord can be any orderable type, such as a number, string, date, timestamp, or boolean.

Examples
SELECT least(3.0, 7.0, 5.0);
| least(3.0, 7.0, 5.0) |
| -------------------- |
| 3.0                  |
SELECT least(3, 7, 5);
| least(3, 7, 5) |
| -------------- |
| 3              |
Either:
  • Returns the element at the specified index in a list.
  • Retrieves the value associated with a key from a map.

Type parameters. E is the element type of the input array or list. K is the key type of the input map. V is the value type of the input map.

Filters a list using a callback function predicate.

Type parameters. T means matching inputs and outputs use the same type.

Alias for array_mode.
Examples
SELECT array_mode(array_constructor(1, 2, 2, 3));
| array_mode(array_constructor(1, 2, 2, 3)) |
| ----------------------------------------- |
| 2                                         |
Returns all N-grams (contiguous subsequences of length n) from an array.

Type parameters. T means matching inputs and outputs use the same type.

Returns true if no element of the array satisfies the predicate.

Type parameters. T means matching inputs and outputs use the same type.

Returns the element at the specified Python-style index in a list.

Type parameters. E is the element type of the input array or list.

Creates a range of integers with Python-like semantics.
Combines multiple lists element-wise into a list of paired structures with Python semantics.

Type parameters. E is the element type of the input array or list.

Removes all null values from an array.

Type parameters. T means matching inputs and outputs use the same type.

Returns an array containing the element repeated count times.

Type parameters. E is the element type of the input array or list.

Parameters
The element to search for. E is the element type of the input array or list.
count:
int32
The number of values to return or repeat.
Generates a sequence of integers with an optional step.
Examples
SELECT sequence(1, 5);
| sequence(1, 5)  |
| --------------- |
| [1, 2, 3, 4, 5] |
Randomly shuffles the elements of an array.

Type parameters. T means matching inputs and outputs use the same type.

Returns a slice of a list starting at the given position for the specified length.

Type parameters. E is the element type of the input array or list.

Returns the element at the specified 1-based index in the array.

Type parameters. T means matching inputs and outputs use the same type.

Applies a transformation function to each element in an array and returns a new array.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Removes the last n elements from the array.

Type parameters. T means matching inputs and outputs use the same type.

Combines two lists element-wise into a list of paired structures.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Parameters
array1:
large_list<item: $T>
The first input array. T means matching inputs and outputs use the same type.
array2:
large_list<item: $U>
The second input array. U is a second generic value type.
Combines two lists element-wise using a callback function to transform paired elements.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type. R is the callback result type.

Parameters
array1:
large_list<item: $T>
The first input array. T means matching inputs and outputs use the same type.
array2:
large_list<item: $U>
The second input array. U is a second generic value type.
function:
($T, $U) => $R
The callback function applied to the elements. T means matching inputs and outputs use the same type. U is a second generic value type. R is the callback result type.
operator alias for list_has_any

Type parameters. E is the element type of the input array or list.

Finds all matches of a regular expression pattern in a string and returns them as a list.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Searches for the first occurrence of a pattern in a string using the Boyer-Moore algorithm. Returns the 0-based byte offset of the first match, or -1 if not found.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Converts an integer to its corresponding ASCII character.
Parameters
n:
int64
The Unicode code point to convert to a character.
Returns the Unicode code point of the only character of the string.
Concatenates two or more strings or lists.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT concat('feature', '_', 'store');
| concat('feature', '_', 'store') |
| ------------------------------- |
| feature_store                   |
Counts the number of non-overlapping regex matches in a string.
Checks if a string ends with a specified suffix.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Examples
SELECT ends_with('feature_store', 'store');
| ends_with('feature_store', 'store') |
| ----------------------------------- |
| true                                |
Returns the Hamming distance of string1 and string2, i.e. the number of positions at which the corresponding characters are different. Note that the two strings must have the same length.
Case-insensitive like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Calculates the Jaccard similarity coefficient between two strings based on character sets.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Calculates the Jaro-Winkler distance between two strings.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
The Jaro-Winkler prefix scaling factor.
Searches for the first occurrence of a pattern in a string using the Knuth-Morris-Pratt algorithm. Returns the 0-based byte offset of the first match, or -1 if not found.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Returns the byte length of a string.
Returns the length of a string, binary, array, or map.

Type parameters. V is the value type of the input map.

Examples
SELECT length('chalk');
| length('chalk') |
| --------------- |
| 5               |
SELECT length(array_constructor(1, 2, 3));
| length(array_constructor(1, 2, 3)) |
| ---------------------------------- |
| 3                                  |
Calculates the Levenshtein distance between two strings.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Checks if a string matches a pattern using SQL LIKE syntax with wildcards.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Calculates the longest common subsequence between two strings.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Converts a string to lowercase.
Parameters
string:
large_string
The input string.
Examples
SELECT lower('Chalk');
| lower('Chalk') |
| -------------- |
| chalk          |
Left pads a string or binary value to a target length.
Examples
SELECT lpad('42', 5, '0');
| lpad('42', 5, '0') |
| ------------------ |
| 00042              |
Removes whitespace or specified characters from the left side of a string.
Examples
SELECT ltrim('  chalk');
| ltrim('  chalk') |
| ---------------- |
| chalk            |
Render a Jinja2 template using the provided JSON context via minijinja.
Normalizes a string using a Unicode normalization form.
Examples
SELECT normalize('chalk');
| normalize('chalk') |
| ------------------ |
| chalk              |
Returns the byte length of a string or binary value.
Examples
SELECT octet_length('chalk');
| octet_length('chalk') |
| --------------------- |
| 5                     |
Calculates the partial ratio similarity between two strings using fuzzy matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Alias for starts_with.
Examples
SELECT starts_with('feature_store', 'feature');
| starts_with('feature_store', 'feature') |
| --------------------------------------- |
| true                                    |
Returns true if all characters in the string are alphanumeric and there is at least one character, matching Python's str.isalnum() behavior.
Returns true if all characters in the string are alphabetic and there is at least one character, matching Python's str.isalpha() behavior.
Returns true if all characters are digit characters and there is at least one character, matching Python's str.isdigit() behavior.
Returns true if all cased characters are lowercase and there is at least one cased character, matching Python's str.islower() behavior.
Returns true if all characters are numeric characters and there is at least one character, matching Python's str.isnumeric() behavior.
Returns true if all characters are whitespace and there is at least one character, matching Python's str.isspace() behavior.
Returns true if the string is titlecased and there is at least one cased character, matching Python's str.istitle() behavior.
Returns true if all cased characters are uppercase and there is at least one cased character, matching Python's str.isupper() behavior.
Strips leading Python whitespace (Unicode-aware), matching Python's str.lstrip() with no arguments.
Removes the prefix from the string if present, matching Python's str.removeprefix().
Removes the suffix from the string if present, matching Python's str.removesuffix().
Strips trailing Python whitespace (Unicode-aware), matching Python's str.rstrip() with no arguments.
Slices a string with exact Python s[start:stop:step] semantics. All integer arguments are nullable (NULL = Python None / unspecified).
Strips leading and trailing Python whitespace (Unicode-aware), matching Python's str.strip() with no arguments.
Returns the first substring matched by a regular expression.
Examples
SELECT regexp_extract('user_123', 'user_([0-9]+)', 1);
| regexp_extract('user_123', 'user_([0-9]+)', 1) |
| ---------------------------------------------- |
| 123                                            |
Returns all substrings matched by a regular expression.
Examples
SELECT regexp_extract_all('a1 b2 c3', '[a-z][0-9]');
| regexp_extract_all('a1 b2 c3', '[a-z][0-9]') |
| -------------------------------------------- |
| [a1, b2, c3]                                 |
Checks if a string matches a regular expression pattern.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Checks if a string matches a regular expression pattern.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Examples
SELECT regexp_like('user_123', '^user_[0-9]+$');
| regexp_like('user_123', '^user_[0-9]+$') |
| ---------------------------------------- |
| true                                     |
Alias for regexp_like.
Examples
SELECT regexp_like('user_123', '^user_[0-9]+$');
| regexp_like('user_123', '^user_[0-9]+$') |
| ---------------------------------------- |
| true                                     |
Replaces or removes substrings matched by a regular expression.
Examples
SELECT regexp_replace('user_123', '[0-9]+', '456');
| regexp_replace('user_123', '[0-9]+', '456') |
| ------------------------------------------- |
| user_456                                    |
Splits ``string`` using the regular expression ``pattern`` into a list of strings.
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Replaces or removes occurrences of a substring.
Examples
SELECT replace('hello chalk', 'hello', 'hi');
| replace('hello chalk', 'hello', 'hi') |
| ------------------------------------- |
| hi chalk                              |
Reverses a string, binary value, or array.

Type parameters. T means matching inputs and outputs use the same type.

Examples
SELECT reverse('chalk');
| reverse('chalk') |
| ---------------- |
| klahc            |
Right pads a string or binary value to a target length.
Examples
SELECT rpad('42', 5, '0');
| rpad('42', 5, '0') |
| ------------------ |
| 42000              |
Removes whitespace or specified characters from the right side of a string.
Examples
SELECT rtrim('chalk  ');
| rtrim('chalk  ') |
| ---------------- |
| chalk            |
Computes the similarity ratio between two strings using sequence matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Splits a string by a delimiter, optionally limiting the number of splits.
Examples
SELECT split('a,b,c', ',');
| split('a,b,c', ',') |
| ------------------- |
| [a, b, c]           |
Splits a string by delimiter and returns the part at the specified index (1-based).
Parameters
string:
large_string
The input string.
delimiter:
large_string
The delimiter used to split or join the string.
index:
int64
The index to read.
Examples
SELECT split_part('features.user.id', '.', 2);
| split_part('features.user.id', '.', 2) |
| -------------------------------------- |
| user                                   |
Checks if a string starts with a specified prefix.
Parameters
string:
large_string
The input string.
substring:
large_string
The substring to search for.
Examples
SELECT starts_with('feature_store', 'feature');
| starts_with('feature_store', 'feature') |
| --------------------------------------- |
| true                                    |
Returns the position of a substring within a string.
Examples
SELECT strpos('chalk data', 'data');
| strpos('chalk data', 'data') |
| ---------------------------- |
| 7                            |
Returns the position of the last matching substring within a string.
Examples
SELECT strrpos('chalk data data', 'data');
| strrpos('chalk data data', 'data') |
| ---------------------------------- |
| 12                                 |
Returns a substring starting at the specified position, optionally with a specified length.
Examples
SELECT substr('feature_store', 9);
| substr('feature_store', 9) |
| -------------------------- |
| store                      |
SELECT substr('feature_store', 1, 7);
| substr('feature_store', 1, 7) |
| ----------------------------- |
| feature                       |
Alias for substr.
Examples
SELECT substr('feature_store', 9);
| substr('feature_store', 9) |
| -------------------------- |
| store                      |
SELECT substr('feature_store', 1, 7);
| substr('feature_store', 1, 7) |
| ----------------------------- |
| feature                       |
Converts a string to title case.
Calculates the token set ratio similarity between two strings using fuzzy matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Calculates the token sort ratio similarity between two strings using fuzzy matching.
Parameters
string1:
large_string
The first input string.
string2:
large_string
The second input string.
Returns the last N characters of the input string, up to at most the length of string.
Removes whitespace or specified characters from both ends of a string.
Examples
SELECT trim('  chalk  ');
| trim('  chalk  ') |
| ----------------- |
| chalk             |
SELECT trim('xychalkyx', 'xy');
| trim('xychalkyx', 'xy') |
| ----------------------- |
| chalk                   |
Normalizes Unicode characters to their closest ASCII equivalents with whitespace normalization.
Parameters
string:
large_string
The input string.
Converts Unicode characters to their closest ASCII equivalents.
Parameters
string:
large_string
The input string.
Converts a string to uppercase.
Parameters
string:
large_string
The input string.
Examples
SELECT upper('chalk');
| upper('chalk') |
| -------------- |
| CHALK          |
Returns the stem of a word using stemming algorithms.
Left-pads a string with zeros to the given width.
Splits a string by delimiter and returns the part at the specified zero-based index.
Parameters
string:
large_string
The input string.
delimiter:
large_string
The delimiter used to split or join the string.
index:
int64
The index to read.
operator alias for not like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
operator alias for not ilike
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Alias for starts_with.
Examples
SELECT starts_with('feature_store', 'feature');
| starts_with('feature_store', 'feature') |
| --------------------------------------- |
| true                                    |
Alias for concat.
operator alias for like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Case-insensitive like
Parameters
string:
large_string
The input string.
pattern:
large_string
The pattern to match.
Returns the current date.
Parameters
None
Converts a timestamp or string to a date.
Examples
SELECT date('2024-01-02');
| date('2024-01-02') |
| ------------------ |
| 2024-01-02         |
Adds a duration or time-unit interval to a date or timestamp.
Examples
SELECT date_add('day', 7, TIMESTAMP '2024-01-02 00:00:00');
| date_add('day', 7, TIMESTAMP '2024-01-02 00:00:00') |
| --------------------------------------------------- |
| 2024-01-09 00:00:00                                 |
Returns the difference between two timestamps in the specified unit.
Parameters
unit:
large_string
The time unit, such as 'second', 'day', or 'month'.
timestamp1:
timestamp[us, tz=UTC]
The first timestamp.
timestamp2:
timestamp[us, tz=UTC]
The second timestamp.
Formats a timestamp as a string using the specified format.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
format:
large_string
The format string.
Truncates a timestamp to the specified time unit (e.g., day, month, year).
Parameters
unit:
large_string
The time unit, such as 'second', 'day', or 'month'.
x:
timestamp[us, tz=UTC]
The input value.
Extracts the day of the month from a date or timestamp.
Overloads
Extracts the day of the month from a timestamp.
Extracts the day of the week from a timestamp.
Extracts the day of the month from a timestamp.
Returns the number of days in the month of the given date.
Extracts the day of the week from a date or timestamp.
Overloads
Extracts the day of the year from a date or timestamp.
Overloads
Formats a datetime using a specified format string.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
format:
large_string
The format string.
Formats a UTC timestamp as a string using a Joda format pattern in the given IANA timezone.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
format:
large_string
The format string.
timezone:
large_string
The IANA timezone name, such as 'America/New_York'.
Parses an ISO 8601 date string into a date value.
Parameters
string:
large_string
The input string.
Parses an ISO 8601 timestamp string into a datetime object.
Parameters
string:
large_string
The input string.
Converts a UNIX timestamp to a timestamp, optionally with a time zone offset.
Examples
SELECT from_unixtime(1700000000);
| from_unixtime(1700000000) |
| ------------------------- |
| 2023-11-14 22:13:20 UTC   |
Extracts the hour from a timestamp.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
Extracts the hour from a timestamp on a given timezone.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
timezone:
large_string
The IANA timezone name, such as 'America/New_York'.
Returns true if the date falls on a weekday (Monday-Friday).
Returns True if the given timestamp is a federal holiday.
Returns the last day of the month for a given date.
Parameters
date:
timestamp[us, tz=UTC]
The input date or timestamp.
Constructs a date from year, month, and day fields.
Parameters
year:
int64
month:
int64
day:
int64
Extracts the millisecond from a timestamp.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
Extracts the minute from a timestamp.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
Extracts the month from a timestamp.
Converts an ISO 8601 string into a datetime.
Parameters
string:
large_string
The input string.
format:
large_string
The format string.
Extracts the quarter of the year from a timestamp.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
Extracts the second from a timestamp.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
Constructs a duration with the given number of days.
Constructs a duration with the given number of hours.
Converts a datetime to an ISO 8601 string format.
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
Examples
SELECT to_iso8601(TIMESTAMP '2024-01-02 03:04:05');
| to_iso8601(TIMESTAMP '2024-01-02 03:04:05') |
| ------------------------------------------- |
| 2024-01-02T03:04:05.000000Z                 |
Converts a duration to microseconds or constructs a duration from microseconds.
Converts a duration to milliseconds or constructs a duration from milliseconds.
Constructs a duration with the given number of minutes.
Constructs a duration with the given number of seconds.
Converts a timestamp or date to nanoseconds since the Unix epoch (UTC). Throws if the value falls outside the int64 ns range (~1677 to ~2262).
Converts a timestamp to Unix timestamp (seconds since epoch).
Parameters
timestamp:
timestamp[us, tz=UTC]
The input timestamp.
Returns the length of the input duration in seconds.
Parameters
duration:
duration[us]
The input duration.
Extracts the week of the year from a timestamp.
Extracts the week of the year from a timestamp.
Extracts the year from a timestamp.
Extracts the year of the ISO week from a date.
Extracts the year of the ISO week from a date.
Overloads
Returns true if all keys in the map match the given predicate.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
($K) => bool
The map key to read or update. K is the key type of the input map.
Returns true if any key in the map matches the given predicate.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
($K) => bool
The map key to read or update. K is the key type of the input map.
Returns true if any value in the map matches the given predicate.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
($V) => bool
The map key to read or update. V is the value type of the input map.
Checks if a map contains any keys that match a given condition.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
($k) => bool
The map key to read or update.
Filters the entries of a map using a callback predicate.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
($K, $V) => bool
The map key to read or update. K is the key type of the input map. V is the value type of the input map.
Creates a map from separate arrays of keys and values.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Retrieves a value from a map by key.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Checks if a map contains any keys that match a given condition.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
$K
The map key to read or update. K is the key type of the input map.
Returns all keys from a map as a list.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
Returns the keys of a map ordered by their top N highest values.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
int64
The map key to read or update.
Returns a subset of a map containing only the specified keys.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Returns the top N entries from a map ordered by value.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
int64
The map key to read or update.
Returns the top N keys from a map ordered by their values.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
int64
The map key to read or update.
Returns the top N values from a map ordered by value.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
int64
The map key to read or update.
Returns all values from a map as a list.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
Merges two maps by applying a function to each matched key and pair of values.

Type parameters. K is the key type of the input map.

Parameters
map:
map<$K, $V1>
The input map. K is the key type of the input map.
key:
map<$K, $V2>
The map key to read or update. K is the key type of the input map.
function:
($K, $V1, $V2) => $V3
The callback function applied to the elements. K is the key type of the input map.
Returns true if no keys in the map match the given predicate.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
($K) => bool
The map key to read or update. K is the key type of the input map.
Returns true if no values in the map match the given predicate.

Type parameters. K is the key type of the input map. V is the value type of the input map.

Parameters
map:
map<$K, $V>
The input map. K is the key type of the input map. V is the value type of the input map.
key:
($V) => bool
The map key to read or update. V is the value type of the input map.
Returns a map with keys transformed by the given function.

Type parameters. V is the value type of the input map.

Parameters
map:
map<$K1, $V>
The input map. V is the value type of the input map.
key:
($K1, $V) => $K2
The map key to read or update. V is the value type of the input map.
Returns a map with values transformed by the given function.

Type parameters. K is the key type of the input map.

Parameters
map:
map<$K, $V1>
The input map. K is the key type of the input map.
key:
($K, $V1) => $V2
The map key to read or update. K is the key type of the input map.
Compute the Beta cdf with given a, b parameters: P(N < value; a, b). The a, b parameters must be positive real numbers and value must be a real value (all of type DOUBLE). The value must lie on the interval [0, 1].
Parameters
a:
double
b:
double
value:
double
The input value.
Compute the Binomial cdf with given numberOfTrials and successProbability (for a single trial): P(N < value). The successProbability must be real value in [0, 1], numberOfTrials and value must be positive integers with numberOfTrials greater or equal to value.
Parameters
value:
int64
The input value.
Compute the Cauchy cdf with given parameters median and scale (gamma): P(N; median, scale). The scale parameter must be a positive double. The value parameter must be a double on the interval [0, 1].
Parameters
median:
double
scale:
double
value:
double
The input value.
Compute the Chi-square cdf with given df (degrees of freedom) parameter: P(N < value; df). The df parameter must be a positive real number, and value must be a non-negative real value (both of type DOUBLE).
Parameters
df:
double
value:
double
The input value.
Compute the F cdf with given df1 (numerator degrees of freedom) and df2 (denominator degrees of freedom) parameters: P(N < value; df1, df2). The numerator and denominator df parameters must be positive real numbers. The value must be a non-negative real number.
Parameters
df1:
double
df2:
double
value:
double
The input value.
Compute the Gamma cdf with given shape and scale parameters: P(N < value; shape, scale). The shape and scale parameters must be positive real numbers. The value must be a non-negative real number.
Parameters
shape:
double
scale:
double
value:
double
The input value.
Compute the inverse of the Beta cdf with given a, b parameters for the cumulative probability (p): P(N < n). The a, b parameters must be positive double values. The probability p must lie on the interval [0, 1].
Parameters
a:
double
b:
double
p:
double
Compute the inverse of the Binomial cdf with given numberOfTrials and successProbability (of a single trial) the cumulative probability (p): P(N <= n). The successProbability and p must be real values in [0, 1] and the numberOfTrials must be a positive integer.
Parameters
p:
double
Compute the inverse of the Cauchy cdf with given parameters median and scale (gamma) for the probability p. The scale parameter must be a positive double. The probability p must be a double on the interval [0, 1].
Parameters
median:
double
scale:
double
p:
double
Compute the inverse of the Chi-square cdf with given df (degrees of freedom) parameter for the cumulative probability (p): P(N < n). The df parameter must be positive real values. The probability p must lie on the interval [0, 1].
Parameters
df:
double
p:
double
Compute the inverse of the Fisher F cdf with a given df1 (numerator degrees of freedom) and df2 (denominator degrees of freedom) parameters for the cumulative probability (p): P(N < n). The numerator and denominator df parameters must be positive real numbers. The probability p must lie on the interval [0, 1].
Parameters
df1:
double
df2:
double
p:
double
Compute the inverse of the Laplace cdf with given mean and scale parameters for the cumulative probability (p): P(N < n). The mean must be a real value and the scale must be a positive real value (both of type DOUBLE). The probability p must lie on the interval [0, 1].
Parameters
mean:
double
scale:
double
p:
double
Compute the inverse of the Normal cdf with given mean and standard deviation (sd) for the cumulative probability (p): P(N < n). The mean must be a real value and the standard deviation must be a real and positive value (both of type DOUBLE). The probability p must lie on the interval (0, 1).
Parameters
mean:
double
sd:
double
p:
double
Compute the inverse of the Poisson cdf with given lambda (mean) parameter for the cumulative probability (p). It returns the value of n so that: P(N <= n; lambda) = p. The lambda parameter must be a positive real number (of type DOUBLE). The probability p must lie on the interval [0, 1).
Parameters
lambda:
double
p:
double
Compute the inverse of the Weibull cdf with given parameters a, b for the probability p. The a, b parameters must be positive double values. The probability p must be a double on the interval [0, 1].
Parameters
a:
double
b:
double
p:
double
Compute the Laplace cdf with given mean and scale parameters: P(N < value; mean, scale). The mean and value must be real values and the scale parameter must be a positive value (all of type DOUBLE).
Parameters
mean:
double
scale:
double
value:
double
The input value.
Compute the Normal cdf with given mean and standard deviation (sd): P(N < value; mean, sd). The mean and value must be real values and the standard deviation must be a real and positive value (all of type DOUBLE).
Parameters
mean:
double
sd:
double
value:
double
The input value.
Compute the Poisson cdf with given lambda (mean) parameter: P(N <= value; lambda). The lambda parameter must be a positive real number (of type DOUBLE) and value must be a non-negative integer.
Parameters
lambda:
double
value:
int32
The input value.
Compute the Weibull cdf with given parameters a, b: P(N <= value). The a and b parameters must be positive doubles and value must also be a double.
Parameters
a:
double
b:
double
value:
double
The input value.
Returns the bucket number for a value in a histogram with uniform bucket widths.
Parameters
x:
double
The input value.
bound1:
double
bound2:
double
n:
int64
The number of equal-width buckets.
Returns the lower bound of the Wilson score interval of a Bernoulli trial process at a confidence specified by the z-score z.
Parameters
The number of successes.
trials:
int64
The number of trials.
z:
double
The z-score for the confidence level.
Returns the upper bound of the Wilson score interval of a Bernoulli trial process at a confidence specified by the z-score z.
Parameters
The number of successes.
trials:
int64
The number of trials.
z:
double
The z-score for the confidence level.
Converts an arbitrary json-compatible value into json.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
The input value. T means matching inputs and outputs use the same type.
Extracts a value from JSON or a JSON string using a path expression.
Returns whether a JSON value or JSON string represents a scalar.
Returns the number of elements in a JSON array.
Parameters
json:
extension<arrow.json>
The input JSON value or JSON string.
Extracts an array from JSON string using a path expression.
Extracts a scalar value from JSON or a JSON string using a JSONPath expression.
Encodes a JSON value into a string
Parameters
json:
extension<arrow.json>
The input JSON value or JSON string.
Returns true when a JSON path resolves to a JSON null value.
Converts an arbitrary value into a JSON string
Parameters
string:
large_string
The input string.
Returns the size of a JSON object or array at a path.
Encodes a JSON value into a string. This is an alias for `json_format`.
Parameters
json:
extension<arrow.json>
The input JSON value or JSON string.
Converts an arbitrary value into a JSON string

Type parameters. T means matching inputs and outputs use the same type.

Parameters
The input value. T means matching inputs and outputs use the same type.
Dispatches a JSON value to the lazy callback matching its runtime JSON type.

Type parameters. R is the callback result type.

Returns true when the input is syntactically valid JSON according to orjson.loads.
Extracts an element from a Python JSON list using Python integer indexing, returning null for non-lists and out-of-range indices.
Either:
  • Extracts a Python JSON boolean, returning null for non-booleans.
  • Extracts a Python JSON boolean after following object keys, returning null for non-booleans.
Either:
  • Extracts a Python JSON dict, returning null for non-dicts.
  • Extracts a Python JSON dict after following object keys, returning null for non-dicts.
Either:
  • Extracts a Python JSON float candidate, returning null for non-numbers.
  • Extracts a Python JSON float candidate after following object keys, returning null for non-numbers.
Either:
  • Extracts a Python JSON integer, returning null for non-integers.
  • Extracts a Python JSON integer after following object keys, returning null for non-integers.
Either:
  • Extracts a Python JSON list, returning null for non-lists.
  • Extracts a Python JSON list after following object keys, returning null for non-lists.
Either:
  • Extracts a Python JSON string, returning null for non-strings.
  • Extracts a Python JSON string after following object keys, returning null for non-strings.
Dispatches a JSON value to the lazy callback matching its runtime JSON type.

Type parameters. R is the callback result type.

Returns true when the input is syntactically valid JSON.
Extracts a nested field from a Python JSON object using string keys, returning null for non-objects and missing keys.
Returns the top-level size of a Python JSON object or array, or 0 for scalar values.
Parses a Python JSON value, returning null for invalid JSON.
Evaluate a Rego query against a policy via the regorus interpreter. Arguments are (policy, query, input_json, data_json); the result is the regorus QueryResults serialized as a JSON string.
Decodes a Base64url-encoded string to binary data.
Parameters
string:
large_string
The input string.
Encodes binary data to a Base64url string.
Parameters
binary:
large_binary
The input binary value.
Decodes URL-encoded characters in a string.
Parameters
value:
large_string
The input value.
URL-encodes special characters in a string.
Parameters
value:
large_string
The input value.
Extracts the fragment portion (after #) from a URL.
Parameters
url:
large_string
The URL to request.
Returns the host from a URL.
Parameters
url:
large_string
The URL to request.
Extracts the value of a specific query parameter from a URL.
Parameters
url:
large_string
The URL to request.
name:
large_string
Returns the path from a URL.
Parameters
url:
large_string
The URL to request.
Extracts the port number from a URL.
Parameters
url:
large_string
The URL to request.
Returns the protocol from a URL.
Parameters
url:
large_string
The URL to request.
Extracts the query string portion (after ?) from a URL.
Parameters
url:
large_string
The URL to request.
Downloads a file from object storage (gs://, s3://, abfs://) and returns the raw bytes. Returns null on error.
Parameters
uri:
large_string
Downloads a file from object storage (gs://, s3://, abfs://) and returns a struct with data, success, error, and metadata.
Parameters
uri:
large_string
Makes a completion request to OpenAI's chat API and returns the response.
Parameters
prompt:
large_string
model:
large_string
= NULL
api_server:
large_string
= NULL
api_key:
large_string
= NULL
max_tokens:
int64
= NULL
temperature:
double
= NULL
service_tier:
large_string
= NULL
response_format:
large_string
= NULL
chat_template_kwargs:
large_string
= NULL
Makes a completion request to OpenAI's chat API and returns the raw JSON response string.
Parameters
prompt:
large_string
model:
large_string
= NULL
api_server:
large_string
= NULL
api_key:
large_string
= NULL
max_tokens:
int64
= NULL
temperature:
double
= NULL
service_tier:
large_string
= NULL
response_format:
large_string
= NULL
chat_template_kwargs:
large_string
= NULL
Invokes an AWS SageMaker endpoint for inference with the provided binary input and returns the binary output.
Parameters
body:
large_binary
The request body.
endpoint:
large_string
The name of the model endpoint to invoke.
content_type:
large_string
The request content type.
target_model:
large_string
target_variant:
large_string
Invokes a Vertex AI endpoint for inference with binary input, returns binary output.
Parameters
body:
large_binary
The request body.
endpoint:
large_string
The name of the model endpoint to invoke.
content_type:
large_string
= NULL
The request content type.
gcp_credentials_override:
large_string
= NULL
dedicated_endpoint_dns:
large_string
= NULL
method:
large_string
= NULL
The HTTP method, such as 'GET' or 'POST'.
api_host:
large_string
= NULL
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geojson:
large_string
The geometry as a GeoJSON string.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
distance:
double
The buffer distance.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
wkt:
large_string
The geometry in WKT format.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
index:
int32
The index to read.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
index:
int32
The index to read.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
wkt:
large_string
The geometry in WKT format.
Geospatial (Presto-flavored Velox geometry function).
Parameters
points:
large_list<item: large_binary>
The array of point geometries.
Geospatial (Presto-flavored Velox geometry function).
Parameters
points:
large_list<item: large_binary>
The array of point geometries.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
x:
double
The input value.
y:
double
The second input value.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
index:
int32
The index to read.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
wkt:
large_string
The geometry in WKT format.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
relation:
large_string
The DE-9IM intersection matrix pattern.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry1:
large_binary
The first input geometry, as WKB.
geometry2:
large_binary
The second input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Geospatial (Presto-flavored Velox geometry function).
Parameters
geometry:
large_binary
The input geometry, as WKB.
Calculates the lat-lon in degrees for a given h3 cell.
Parameters
cell:
large_string
The H3 cell identifier.
Calculates the lat-lon for a given h3 cell.
Parameters
cell:
large_string
The H3 cell identifier.
Converts Avro binary data to a structured format using an Avro schema.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
schema:
large_string
The schema definition.
A (possibly null) struct value whose type defines the result shape. T means matching inputs and outputs use the same type.
binary:
large_binary
The input binary value.
Decodes a Base64-encoded string to binary data.
Parameters
string:
large_string
The input string.
Convert a 32-bit big-endian bytes value to an integer.
Convert a 64-bit big-endian bytes value to an integer.
Converts a hexadecimal string to binary data.
Parameters
string:
large_string
The input string.
Decodes the 32-bit big-endian binary representation of an IEEE 754 floating-point value.
Parameters
binary:
large_binary
The input binary value.
Decodes the 64-bit big-endian binary representation of an IEEE 754 floating-point value.
Parameters
binary:
large_binary
The input binary value.
Decompress snappy-compressed binary data.
gunzip the input binary data.
Converts protobuf binary data to a structured format.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
descriptor:
large_binary
The serialized protobuf FileDescriptorSet.
message_name:
large_string
The fully-qualified protobuf message name.
A (possibly null) struct value whose type defines the result shape. T means matching inputs and outputs use the same type.
binary:
large_binary
The input binary value.
Converts protobuf binary data to a structured format, recording parse errors with row attribution.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
descriptor:
large_binary
The serialized protobuf FileDescriptorSet.
message_name:
large_string
The fully-qualified protobuf message name.
A (possibly null) struct value whose type defines the result shape. T means matching inputs and outputs use the same type.
binary:
large_binary
The input binary value.
Decodes UTF-8 encoded binary data using Python's strict bytes.decode() semantics.
Parameters
binary:
large_binary
The input binary value.
Converts structured data to protobuf binary format.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
descriptor:
large_binary
The serialized protobuf FileDescriptorSet.
message_name:
large_string
The fully-qualified protobuf message name.
The input value. T means matching inputs and outputs use the same type.
Encodes binary data to a Base64 string.
Parameters
binary:
large_binary
The input binary value.
Encodes an integer into a 32-bit big-endian binary representation.
Parameters
integer:
int32
Encodes a bigint into a 64-bit big-endian binary representation.
Parameters
bigint:
int64
Converts binary data to its hexadecimal string representation.
Parameters
binary:
large_binary
The input binary value.
Encodes a float as a 32-bit big-endian binary in IEEE 754 format.
Parameters
real:
float
Encodes a double as a 64-bit big-endian binary in IEEE 754 format.
Parameters
double:
double
Snappy-compress binary data.
Calculates the CRC32 checksum of binary data.
Parameters
binary:
large_binary
The input binary value.
Computes HMAC-MD5 authentication code for data using a secret key.
Parameters
binary:
large_binary
The input binary value.
key:
large_binary
The map key to read or update.
Computes HMAC-SHA1 authentication code for data using a secret key.
Parameters
binary:
large_binary
The input binary value.
key:
large_binary
The map key to read or update.
Computes HMAC-SHA256 authentication code for data using a secret key.
Parameters
binary:
large_binary
The input binary value.
key:
large_binary
The map key to read or update.
Computes HMAC-SHA512 authentication code for data using a secret key.
Parameters
binary:
large_binary
The input binary value.
key:
large_binary
The map key to read or update.
Computes the MD5 hash of binary data.
Parameters
binary:
large_binary
The input binary value.
Computes the SHA-1 hash of binary data.
Parameters
binary:
large_binary
The input binary value.
Computes the SHA-256 hash of binary data.
Parameters
binary:
large_binary
The input binary value.
Computes the SHA-512 hash of binary data.
Parameters
binary:
large_binary
The input binary value.
Computes a 32-bit SpookyHash V2 hash of binary data.
Parameters
binary:
large_binary
The input binary value.
Computes a 64-bit SpookyHash V2 hash of binary data.
Parameters
binary:
large_binary
The input binary value.
Computes a 64-bit XXHash of binary data, optionally with a seed.
Converts a string representation of a number in a given base to an integer.
Parameters
string:
large_string
The input string.
radix:
int64
The base (radix) to convert to.
Decodes UTF-8 encoded binary data, optionally replacing invalid sequences.
Converts an integer to its string representation in the specified base.
Parameters
value:
int64
The integer to convert.
radix:
int64
The base (radix) to convert to.
Encodes a string to UTF-8 binary data.
Parameters
string:
large_string
The input string.
Runs a SQL query directly against a registered datasource and returns the datasource result as a table. Use this when the SQL should be interpreted by the datasource dialect instead of the ChalkSQL dialect.
Parameters
The name of the registered datasource to query.
query:
string
The SQL query to execute against the datasource.
Examples
SELECT * FROM datasource_query('my_postgres', 'SELECT id, email FROM public.users LIMIT 10');
Computes an Amazon Titan text embedding for the input string via AWS Bedrock and returns the embedding as a float vector.
Parameters
text:
large_string
The input text.
model_id:
large_string
The model identifier to invoke.
dimensions:
int64
= NULL
The embedding dimension count.
normalize:
bool
= NULL
aws_access_key_id_override:
large_string
= NULL
aws_session_token_override:
large_string
= NULL
aws_role_arn_override:
large_string
= NULL
aws_region_override:
large_string
= NULL
aws_profile_name_override:
large_string
= NULL
Invokes an AWS Bedrock model via InvokeModel with the provided binary request body and returns the raw binary response body.
Parameters
body:
large_binary
The request body.
model_id:
large_string
The model identifier to invoke.
content_type:
large_string
= NULL
The request content type.
accept:
large_string
= NULL
The response MIME type to request.
aws_access_key_id_override:
large_string
= NULL
aws_session_token_override:
large_string
= NULL
aws_role_arn_override:
large_string
= NULL
aws_region_override:
large_string
= NULL
aws_profile_name_override:
large_string
= NULL
Reads the estimated distinct count off a CPC sketch, rounded to the nearest integer.
Unions CPC sketches into a single sketch. Null arguments are skipped; all-null input yields null.
Constructs a duration from a microsecond count.
Parameters
The number of microseconds.
Raises an error with the specified error message.
Alias for strpos.
Examples
SELECT strpos('chalk data', 'data');
| strpos('chalk data', 'data') |
| ---------------------------- |
| 7                            |
Calculates the Jaro similarity between two strings.
Parameters
a:
large_string
b:
large_string
Calculates the Jaro-Winkler similarity between two strings.
Either:
  • Returns the length of the binary in bytes.
  • Returns the length of a string in characters.
  • Returns the number of elements in a list.

Type parameters. V is the value type of the input map.

Examples
SELECT length('chalk');
| length('chalk') |
| --------------- |
| 5               |
Makes an embedding request to OpenAI's embeddings API and returns the response.
Parameters
input:
large_string
The input value.
model:
large_string
= NULL
api_server:
large_string
= NULL
api_key:
large_string
= NULL
dimensions:
int64
= NULL
The embedding dimension count.
Applies a reduce function to each element in an array and returns the accumulated value.

Type parameters. T means matching inputs and outputs use the same type. U is a second generic value type.

Parameters
array:
large_list<item: $T>
The input array or list. T means matching inputs and outputs use the same type.
U is a second generic value type.
inputFunction:
($U, $T) => $U
T means matching inputs and outputs use the same type. U is a second generic value type.
Alias for ends_with.
Examples
SELECT ends_with('feature_store', 'store');
| ends_with('feature_store', 'store') |
| ----------------------------------- |
| true                                |
Attempts to execute an expression and handles any errors gracefully.

Type parameters. T means matching inputs and outputs use the same type.

Parameters
The input value. T means matching inputs and outputs use the same type.
Generates a UUID string: a random version 4 UUID with no arguments, or the deterministic version 5 UUID of a name within a namespace UUID with two arguments.
Examples
SELECT uuid_string();
SELECT uuid_string('fe971b24-9572-4005-b22f-351e9c09274d', 'chalk');
Cosine distance (1 - cosine similarity) between two vectors.
Overloads