Project: Druid (App Definition and Development / Database)
File: sql-functions.md

id: sql-functions title: "All Druid SQL functions" sidebar_label: "All functions" <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership. The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License. You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the License for the ~ specific language governing permissions and limitations ~ under the License. --> :::info Apache Druid supports two query languages: Druid SQL and . This document describes the SQL language. ::: This page provides a reference of all Druid SQL functions in alphabetical order. Click the linked function type for documentation on a particular function. `ABS(<NUMERIC>)` Function type: Calculates the absolute value of a numeric expression. `ACOS(<NUMERIC>)` Function type: Calculates the arc cosine of a numeric expression. `ANY_VALUE(expr, [maxBytesPerValue, [aggregateMultipleValues]])` Function type: Returns any value of the specified expression. `APPROXCOUNTDISTINCT(expr)` Function type: Counts distinct values of a regular column or a prebuilt sketch column. `APPROXCOUNTDISTINCT_BUILTIN(expr)` Function type: Counts distinct values of a string, numeric, or `hyperUnique` column using Druid's built-in `cardinality` or `hyperUnique` aggregators. `APPROXCOUNTDISTINCTDSHLL(expr, [<NUMERIC>, <CHARACTER>])` Function type: Counts distinct values of an HLL sketch column or a regular column. `APPROXCOUNTDISTINCTDSTHETA(expr, [<NUMERIC>])` Function type: Counts distinct values of a Theta sketch column or a regular column. `APPROX_QUANTILE(expr, <NUMERIC>, [<NUMERIC>])` Function type: Deprecated in favor of `APPROXQUANTILEDS`. `APPROXQUANTILEDS(expr, <NUMERIC>, [<NUMERIC>])` Function type: Computes approximate quantiles on a Quantiles sketch column or a regular numeric column. `APPROXQUANTILEFIXED_BUCKETS(expr, <NUMERIC>, <NUMERIC>, <NUMERIC>, <NUMERIC>, [<CHARACTER>])` Function type: Computes approximate quantiles on fixed buckets histogram column or a regular numeric column. `ARRAY[expr1, expr2, ...]` Function type: Constructs a SQL ARRAY literal from the expression arguments. The arguments must be of the same type. `ARRAY_AGG([DISTINCT] expr, [<NUMERIC>])` Function type: Returns an array of all values of the specified expression. `ARRAY_APPEND(arr1, expr)` Function type: Appends `expr` to `arr`, the resulting array type determined by the type of `arr1`. `ARRAY_CONCAT(arr1, arr2)` Function type: Concatenates `arr2` to `arr1`. The resulting array type is determined by the type of `arr1`.| `ARRAYCONCATAGG([DISTINCT] expr, [<NUMERIC>])` Function type: Concatenates array inputs into a single array. `ARRAY_CONTAINS(arr, expr)` Function type: If `expr` is a scalar type, returns true if `arr` contains `expr`. If `expr` is an array, returns 1 if `arr` contains all elements of `expr`. Otherwise returns false. `ARRAY_LENGTH(arr)` Function type: Returns length of the array expression. `ARRAY_OFFSET(arr, long)` Function type: Returns the array element at the 0-based index supplied, or null for an out of range index. `ARRAYOFFSETOF(arr, expr)` Function type: Returns the 0-based index of the first occurrence of `expr` in the array. If no matching elements exist in the array, returns `null` or `-1` if `druid.generic.useDefaultValueForNull=true` (deprecated legacy mode). Function type: `ARRAY_ORDINAL(arr, long)` Returns the array element at the 1-based index supplied, or null for an out of range

`ARRAYORDINALOF(arr, expr)` Function type: Returns the 1-based index of the first occurrence of `expr` in the array. If no matching elements exist in the array, returns `null` or `-1` if `druid.generic.useDefaultValueForNull=true` (deprecated legacy mode). `ARRAY_OVERLAP(arr1, arr2)` Function type: Returns true if `arr1` and `arr2` have any elements in common, else false. `SCALARINARRAY(expr, arr)` Function type: Returns true if the scalar `expr` is present in `arr`. Otherwise, returns false if the scalar `expr` is non-null or `UNKNOWN` if the scalar `expr` is `NULL`. Returns `UNKNOWN` if `arr` is `NULL`. `ARRAY_PREPEND(expr, arr)` Function type: Prepends `expr` to `arr` at the beginning, the resulting array type determined by the type of `arr`. `ARRAY_SLICE(arr, start, end)` Function type: Returns the subarray of `arr` from the 0-based index `start` (inclusive) to `end` (exclusive). Returns `null`, if `start` is less than 0, greater than length of `arr`, or greater than `end`. `ARRAYTOMV(arr)` Function type: Converts an `ARRAY` of any type into a multi-value string `VARCHAR`. `ARRAYTOSTRING(arr, str)` Function type: Joins all elements of `arr` by the delimiter specified by `str`. `ASIN(<NUMERIC>)` Function type: Calculates the arc sine of a numeric expression. `ATAN(<NUMERIC>)` Function type: Calculates the arc tangent of a numeric expression. `ATAN2(<NUMERIC>, <NUMERIC>)` Function type: Calculates the arc tangent of the two arguments. `AVG(<NUMERIC>)` Function type: Calculates the average of a set of values. `BIT_AND(expr)` Function type: Performs a bitwise AND operation on all input values. `BIT_OR(expr)` Function type: Performs a bitwise OR operation on all input values. `BIT_XOR(expr)` Function type: Performs a bitwise XOR operation on all input values. `BITWISE_AND(expr1, expr2)` Function type: Returns the bitwise AND between the two expressions, that is, `expr1 & expr2`. `BITWISE_COMPLEMENT(expr)` Function type: Returns the bitwise NOT for the expression, that is, `~expr`. `BITWISECONVERTDOUBLETOLONG_BITS(expr)` Function type: Converts the bits of an IEEE 754 floating-point double value to a long. `BITWISECONVERTLONGBITSTO_DOUBLE(expr)` Function type: Converts a long to the IEEE 754 floating-point double specified by the bits stored in the long. `BITWISE_OR(expr1, expr2)` Function type: Returns the bitwise OR between the two expressions, that is, `expr1 | expr2`. `BITWISESHIFTLEFT(expr1, expr2)` Function type: Returns a bitwise left shift of expr1, that is, `expr1 << expr2`. `BITWISESHIFTRIGHT(expr1, expr2)` Function type: Returns a bitwise right shift of expr1, that is, `expr1 >> expr2`. `BITWISE_XOR(expr1, expr2)` Function type: Returns the bitwise exclusive OR between the two expressions, that is, `expr1 ^ expr2`. `BLOOM_FILTER(expr, <NUMERIC>)` Function type: Computes a Bloom filter from values produced by the specified expression. `BLOOMFILTERTEST(expr, <STRING>)` Function type: Returns true if the expression is contained in a Base64-serialized Bloom filter. `BTRIM(<CHARACTER>, [<CHARACTER>])` Function type: Trims characters from both the leading and trailing ends of an expression. `CASE expr WHEN value1 THEN result1 \[ WHEN value2 THEN result2 ... \] \[ ELSE resultN \] END` Function type: Returns a result based on a given condition. `CAST(value AS TYPE)` Function type: Converts a value into the specified data type. `CEIL(<TIMESTAMP> TO <TIME_UNIT>)` Function type: Rounds up a timestamp by a given time unit. `CEIL(<NUMERIC>)` Function type: Calculates the smallest integer value greater than or equal to the numeric expression. `CHAR_LENGTH(expr)` Function type: Alias for . `CHARACTER_LENGTH(expr)` Function type: Alias for . `COALESCE(expr, expr, ...)` Function type: Returns the first non-null value. `CONCAT(expr, expr...)` Function type: Concatenates a list of expressions. `CONTAINS_STRING(<CHARACTER>, <CHARACTER>)` Function type: Finds whether a string is in a given expression,

`COS(<NUMERIC>)` Function type: Calculates the trigonometric cosine of an angle expressed in radians. `COT(<NUMERIC>)` Function type: Calculates the trigonometric cotangent of an angle expressed in radians. `COUNT([DISTINCT] expr)` `COUNT(*)` Function type: Counts the number of rows. `CUME_DIST()` Function type: Returns the cumulative distribution of the current row within the window calculated as `number of window rows at the same rank or higher than current row` / `total window rows`. The return value ranges between `1/number of rows` and 1. `CURRENT_DATE` Function type: Returns the current date in the connection's time zone. `CURRENT_TIMESTAMP` Function type: Returns the current timestamp in the connection's time zone. `DATE_TRUNC(<CHARACTER>, <TIMESTAMP>)` Function type: Rounds down a timestamp by a given time unit. `DECODEBASE64COMPLEX(dataType, expr)` Function type: Decodes a Base64-encoded string into a complex data type, where `dataType` is the complex data type and `expr` is the Base64-encoded string to decode. `DECODEBASE64UTF8(expr)` Function type: Decodes a Base64-encoded string into a UTF-8 encoded string. `DEGREES(<NUMERIC>)` Function type: Converts an angle from radians to degrees. `DENSE_RANK()` Function type: Returns the rank for a row within a window without gaps. For example, if two rows tie for a rank of 1, the subsequent row is ranked 2. `DIV(x, y)` Function type: Returns the result of integer division of `x` by `y`. `DS_CDF(expr, splitPoint0, splitPoint1, ...)` Function type: Returns a string representing an approximation to the Cumulative Distribution Function given the specified bin definition. `DSGETQUANTILE(expr, fraction)` Function type: Returns the quantile estimate corresponding to `fraction` from a quantiles sketch. `DSGETQUANTILES(expr, fraction0, fraction1, ...)` Function type: Returns a string representing an array of quantile estimates corresponding to a list of fractions from a quantiles sketch. `DS_HISTOGRAM(expr, splitPoint0, splitPoint1, ...)` Function type: Returns a string representing an approximation to the histogram given the specified bin definition. `DS_HLL(expr, [lgK, tgtHllType])` Function type: Creates an HLL sketch on a column containing HLL sketches or a regular column. `DSQUANTILESUMMARY(expr)` Function type: Returns a string summary of a quantiles sketch. `DSQUANTILESSKETCH(expr, [k])` Function type: Creates a Quantiles sketch on a column containing Quantiles sketches or a regular column. `DS_RANK(expr, value)` Function type: Returns an approximate rank between 0 and 1 of a given value, in which the rank signifies the fraction of the distribution less than the given value. `DS_THETA(expr, [size])` Function type: Creates a Theta sketch on a column containing Theta sketches or a regular column. `DSTUPLEDOUBLES(expr, [nominalEntries])` `DSTUPLEDOUBLES(dimensionColumnExpr, metricColumnExpr, ..., [nominalEntries])` Function type: Creates a Tuple sketch which contains an array of double values as the Summary Object. If the last value of the array is a numeric literal, Druid assumes that the value is an override parameter for . `DSTUPLEDOUBLES_INTERSECT(expr, ..., [nominalEntries])` Function type: Returns an intersection of Tuple sketches which each contain an array of double values as their Summary Objects. The values contained in the Summary Objects are summed when combined. If the last value of the array is a numeric literal, Druid assumes that the value is an override parameter for . `DSTUPLEDOUBLESMETRICSSUM_ESTIMATE(expr)` Function type: Computes approximate sums of the values contained within a Tuple sketch which contains an array of double values as the Summary Object. `DSTUPLEDOUBLES_NOT(expr, ..., [nominalEntries])` Function type: Returns a set difference of Tuple sketches which each contain an array of double values as their Summary Objects. The values contained in the Summary Object are preserved as

If the last value of the array is a numeric literal, Druid assumes that the value is an override parameter for . `DSTUPLEDOUBLES_UNION(expr, ..., [nominalEntries])` Function type: Returns a union of Tuple sketches which each contain an array of double values as their Summary Objects. The values contained in the Summary Objects are summed when combined. If the last value of the array is a numeric literal, Druid assumes that the value is an override parameter for . `EARLIEST(expr, [maxBytesPerValue])` Function type: Returns the value of a numeric or string expression corresponding to the earliest `time` value. `EARLIEST_BY(expr, timestampExpr, [maxBytesPerValue])` Function type: Returns the value of a numeric or string expression corresponding to the earliest time value from `timestampExpr`. `EXP(<NUMERIC>)` Function type: Calculates e raised to the power of the numeric expression. `EXTRACT(<TIME_UNIT> FROM <TIMESTAMP>)` Function type: Extracts the value of some unit of the timestamp, optionally from a certain time zone, and returns the number. `FIRST_VALUE(expr)` Function type: Returns the value evaluated for the expression for the first row within the window. `FLOOR(<TIMESTAMP> TO <TIME_UNIT>)` Function type: Rounds down a timestamp by a given time unit. `FLOOR(<NUMERIC>)` Function type: Calculates the largest integer value less than or equal to the numeric expression. `GREATEST([expr1, ...])` Function type: Returns the maximum value from the provided arguments. `GROUPING(expr, expr...)` Function type: Returns a number for each output row of a groupBy query, indicating whether the specified dimension is included for that row. `HLLSKETCHESTIMATE(expr, [round])` Function type: Returns the distinct count estimate from an HLL sketch. `HLLSKETCHESTIMATEWITHERROR_BOUNDS(expr, [numStdDev])` Function type: Returns the distinct count estimate and error bounds from an HLL sketch. `HLLSKETCHTO_STRING(expr)` Function type: Returns a human-readable string representation of an HLL sketch. `HLLSKETCHUNION([lgK, tgtHllType], expr0, expr1, ...)` Function type: Returns a union of HLL sketches. `HUMANREADABLEBINARYBYTEFORMAT(value[, precision])` Function type: Converts an integer byte size into human-readable IEC format. `HUMANREADABLEDECIMALBYTEFORMAT(value[, precision])` Function type: Converts a byte size into human-readable SI format. `HUMANREADABLEDECIMAL_FORMAT(value[, precision])` Function type: Converts a byte size into human-readable SI format with single-character units. `ICONTAINS_STRING(<expr>, str)` Function type: Finds whether a string is in a given expression, case-insensitive. `IPV4_MATCH(address, subnet)` Function type: Returns true if the IPv4 `address` belongs to the `subnet` literal, else false. `IPV4_PARSE(address)` Function type: Parses `address` into an IPv4 address stored as an integer. `IPV4_STRINGIFY(address)` Function type: Converts `address` into an IPv4 address in dot-decimal notation. `IPV6_MATCH(address, subnet)` Function type: Returns true if the IPv6 `address` belongs to the `subnet` literal, else false. Function type: `JSON_KEYS(expr, path)` Returns an array of field names from `expr` at the specified `path`. Function type: `JSON_OBJECT(KEY expr1 VALUE expr2[, KEY expr3 VALUE expr4, ...])` Constructs a new `COMPLEX<json>` object. The `KEY` expressions must evaluate to string types. The `VALUE` expressions can be composed of any input type, including other `COMPLEX<json>` values. `JSONOBJECT` can accept colon-separated key-value pairs. The following syntax is equivalent: `JSONOBJECT(expr1:expr2[, expr3:expr4, ...])`. Function type: `JSON_PATHS(expr)` Returns an array of all paths which refer to literal values in `expr` in JSONPath format. Function type: `JSON_QUERY(expr, path)` Extracts a `COMPLEX<json>` value from `expr`, at the specified `path`. Function type: `JSONQUERYARRAY(expr, path)` Extracts an `ARRAY<COMPLEX<json>>` value from `expr` at the specified `path`. If value is not an `ARRAY`, it gets translated into a single element `ARRAY` containing the value at

The primary use of this function is to extract arrays of objects to use as inputs to other . Function type: `JSON_VALUE(expr, path [RETURNING sqlType])` Extracts a literal value from `expr` at the specified `path`. If you specify `RETURNING` and an SQL type name (such as `VARCHAR`, `BIGINT`, `DOUBLE`, etc) the function plans the query using the suggested type. Otherwise, it attempts to infer the type based on the context. If it can't infer the type, it defaults to `VARCHAR`. `LAG(expr[, offset])` Function type: If you do not supply an `offset`, returns the value evaluated at the row preceding the current row. Specify an offset number `n` to return the value evaluated at `n` rows preceding the current one. `LAST_VALUE(expr)` Function type: Returns the value evaluated for the expression for the last row within the window. `LATEST(expr, [maxBytesPerValue])` Function type: Returns the value of a numeric or string expression corresponding to the latest `time` value. `LATEST_BY(expr, timestampExpr, [maxBytesPerValue])` Function type: Returns the value of a numeric or string expression corresponding to the latest time value from `timestampExpr`. `LEAD(expr[, offset])` Function type: If you do not supply an `offset`, returns the value evaluated at the row following the current row. Specify an offset number `n` to return the value evaluated at `n` rows following the current one; if there is no such row, returns the given default value. `LEAST([expr1, ...])` Function type: Returns the minimum value from the provided arguments. `LEFT(expr, [length])` Function type: Returns the leftmost number of characters from an expression. `LENGTH(expr)` Function type: Returns the length of the expression in UTF-16 encoding. `LN(expr)` Function type: Calculates the natural logarithm of the numeric expression. `LOG10(expr)` Function type: Calculates the base-10 of the numeric expression. `LOOKUP(<CHARACTER>, <CHARACTER>[, <CHARACTER>])` Function type: Looks up the expression in a registered query-time lookup table. `LOWER(expr)` Function type: Returns the expression in lowercase. `LPAD(<CHARACTER>, <INTEGER>, [<CHARACTER>])` Function type: Returns the leftmost number of characters from an expression, optionally padded with the given characters. `LTRIM(<CHARACTER>, [<CHARACTER>])` Function type: Trims characters from the leading end of an expression. `MAX(expr)` Function type: Returns the maximum value of a set of values. `MILLISTOTIMESTAMP(millis_expr)` Function type: Converts a number of milliseconds since epoch into a timestamp. `MIN(expr)` Function type: Returns the minimum value of a set of values. `MOD(x, y)` Function type: Calculates x modulo y, or the remainder of x divided by y. `MV_APPEND(arr1, expr)` Function type: Adds the expression to the end of the array. `MV_CONCAT(arr1, arr2)` Function type: Concatenates two arrays. `MV_CONTAINS(arr, expr)` Function type: Returns true if the expression is in the array, false otherwise. `MVFILTERNONE(expr, arr)` Function type: Filters a multi-value expression to include no values contained in the array. `MVFILTERONLY(expr, arr)` Function type: Filters a multi-value expression to include only values contained in the array. `MV_LENGTH(arr)` Function type: Returns the length of an array expression. `MV_OFFSET(arr, long)` Function type: Returns the array element at the given zero-based index. `MVOFFSETOF(arr, expr)` Function type: Returns the zero-based index of the first occurrence of a given expression in the array. `MV_ORDINAL(arr, long)` Function type: Returns the array element at the given one-based index. `MVORDINALOF(arr, expr)` Function type: Returns the one-based index of the first occurrence of a given expression. `MV_OVERLAP(arr1, arr2)` Function type: Returns true if the two arrays have any elements in common, false

`MV_PREPEND(expr, arr)` Function type: Adds the expression to the beginning of the array. `MV_SLICE(arr, start, end)` Function type: Returns a slice of the array from the zero-based start and end indexes. `MVTOSTRING(arr, str)` Function type: Joins all elements of the array together by the given delimiter. `NTILE(tiles)` Function type: Divides the rows within a window as evenly as possible into the number of tiles, also called buckets, and returns the value of the tile that the row falls into. `NULLIF(value1, value2)` Function type: Returns NULL if two values are equal, else returns the first value. `NVL(e1, e2)` Function type: Returns `e2` if `e1` is null, else returns `e1`. Function type: `PARSE_JSON(expr)` Parses `expr` into a `COMPLEX<json>` object. This operator deserializes JSON values when processing them, translating stringified JSON into a nested structure. If the input is not a `VARCHAR` or it is invalid JSON, this function will result in an error. `PARSE_LONG(<CHARACTER>, [<INTEGER>])` Function type: Converts a string into a BIGINT with the given base or into a DECIMAL data type if the base is not specified. `PERCENT_RANK()` Function type: Returns the relative rank of the row calculated as a percentage according to the formula: `RANK() OVER (window) / COUNT(1) OVER (window)`. `POSITION(<CHARACTER> IN <CHARACTER> [FROM <INTEGER>])` Function type: Returns the one-based index position of a substring within an expression, optionally starting from a given one-based index. `POWER(expr, power)` Function type: Calculates a numerical expression raised to the specified power. `RADIANS(expr)` Function type: Converts an angle from degrees to radians. `RANK()` Function type: Returns the rank with gaps for a row within a window. For example, if two rows tie for rank 1, the next rank is 3. `REGEXP_EXTRACT(<CHARACTER>, <CHARACTER>, [<INTEGER>])` Function type: Applies a regular expression to the string expression and returns the nth match. `REGEXP_LIKE(<CHARACTER>, <CHARACTER>)` Function type: Returns true or false signifying whether the regular expression finds a match in the string expression. `REGEXP_REPLACE(<CHARACTER>, <CHARACTER>, <CHARACTER>)` Function type: Replaces all occurrences of a regular expression in a string expression with a replacement string. The replacement string may refer to capture groups using `$1`, `$2`, etc. `REPEAT(<CHARACTER>, [<INTEGER>])` Function type: Repeats the string expression an integer number of times. `REPLACE(expr, pattern, replacement)` Function type: Replaces a pattern with another string in the given expression. `REVERSE(expr)` Function type: Reverses the given expression. `RIGHT(expr, [length])` Function type: Returns the rightmost number of characters from an expression. `ROUND(expr[, digits])` Function type: Calculates the rounded value for a numerical expression. `ROW_NUMBER()` Function type: Returns the number of the row within the window starting from 1. `RPAD(<CHARACTER>, <INTEGER>, [<CHARACTER>])` Function type: Returns the rightmost number of characters from an expression, optionally padded with the given characters. `RTRIM(<CHARACTER>, [<CHARACTER>])` Function type: Trims characters from the trailing end of an expression. `SAFE_DIVIDE(x, y)` Function type: Returns `x` divided by `y`, guarded on division by 0. `SIN(expr)` Function type: Calculates the trigonometric sine of an angle expressed in radians. `SQRT(expr)` Function type: Calculates the square root of a numeric expression. `STDDEV(expr)` Function type: Alias for . `STDDEV_POP(expr)` Function type: Calculates the population standard deviation of a set of values. `STDDEV_SAMP(expr)` Function type: Calculates the sample standard deviation of a set of values. `STRING_AGG(expr, separator, [size])` Function type: Collects all values of an expression into a single

`STRINGTOARRAY(str1, str2)` Function type: Splits `str1` into an array on the delimiter specified by `str2`, which is a regular expression. `STRING_FORMAT(pattern[, args...])` Function type: Returns a string formatted in accordance to Java's String.format method. `STRINGTOMV(str1, str2)` Function type: Splits `str1` into an multi-value string on the delimiter specified by `str2`, which is a regular expression. `STRLEN(expr)` Function type: Alias for . `STRPOS(<CHARACTER>, <CHARACTER>)` Function type: Returns the one-based index position of a substring within an expression. `SUBSTR(<CHARACTER>, <INTEGER>, [<INTEGER>])` Function type: Alias for . `SUBSTRING(<CHARACTER>, <INTEGER>, [<INTEGER>])` Function type: Returns a substring of the expression starting at a given one-based index. `SUM(expr)` Function type: Calculates the sum of a set of values. `TAN(expr)` Function type: Calculates the trigonometric tangent of an angle expressed in radians. `TDIGESTGENERATESKETCH(expr, [compression])` Function type: Generates a T-digest sketch from values of the specified expression. `TDIGEST_QUANTILE(expr, quantileFraction, [compression])` Function type: Returns the quantile for the specified fraction from a T-Digest sketch constructed from values of the expression. `TEXTCAT(<CHARACTER>, <CHARACTER>)` Function type: Concatenates two string expressions. `THETASKETCHESTIMATE(expr)` Function type: Returns the distinct count estimate from a Theta sketch. `THETASKETCHESTIMATEWITHERROR_BOUNDS(expr, errorBoundsStdDev)` Function type: Returns the distinct count estimate and error bounds from a Theta sketch. `THETASKETCHINTERSECT([size], expr0, expr1, ...)` Function type: Returns an intersection of Theta sketches. `THETASKETCHNOT([size], expr0, expr1, ...)` Function type: Returns a set difference of Theta sketches. `THETASKETCHUNION([size], expr0, expr1, ...)` Function type: Returns a union of Theta sketches. `TIME_CEIL(<TIMESTAMP>, <period>, [<origin>, [<timezone>]])` Function type: Rounds up a timestamp by a given time period, optionally from some reference time or timezone. `TIME_EXTRACT(<TIMESTAMP>, [<unit>, [<timezone>]])` Function type: Extracts the value of some unit of the timestamp and returns the number. `TIME_FLOOR(<TIMESTAMP>, <period>, [<origin>, [<timezone>]])` Function type: Rounds down a timestamp by a given time period, optionally from some reference time or timezone. `TIME_FORMAT(<TIMESTAMP>, [<pattern>, [<timezone>]])` Function type: Formats a timestamp as a string. `TIMEININTERVAL(<TIMESTAMP>, <CHARACTER>)` Function type: Returns whether a timestamp is contained within a particular interval, formatted as a string. `TIMEPARSE(<stringexpr>, [<pattern>, [<timezone>]])` Function type: Parses a string into a timestamp. `TIME_SHIFT(<TIMESTAMP>, <period>, <step>, [<timezone>])` Function type: Shifts a timestamp forwards or backwards by a given number of time units. `TIMESTAMPTOMILLIS(<TIMESTAMP>)` Function type: Returns the number of milliseconds since epoch for the given timestamp. `TIMESTAMPADD(<unit>, <count>, <TIMESTAMP>)` Function type: Adds a certain amount of time to a given timestamp. `TIMESTAMPDIFF(<unit>, <TIMESTAMP>, <TIMESTAMP>)` Function type: Takes the difference between two timestamps, returning the results in the given units. Function type: `TOJSONSTRING(expr)` Serializes `expr` into a JSON string. `TRIM([BOTH|LEADING|TRAILING] [<chars> FROM] expr)` Function type: Trims the leading or trailing characters of an expression. `TRUNC(expr[, digits])` Function type: Alias for . `TRUNCATE(expr[, digits])` Function type: Truncates a numerical expression to a specific number of decimal digits. Function type: `TRYPARSEJSON(expr)` Parses `expr` into a `COMPLEX<json>` object. This operator deserializes JSON values when processing them, translating stringified JSON into a nested structure. If the input is not a `VARCHAR` or it is invalid JSON, this function will result in a `NULL` value. `UNNEST(sourceexpression) as tablealiasname(columnalias_name)` Unnests a source expression that includes arrays into a target column with an aliased name. For more information, see . `UPPER(expr)` Function type: Returns the expression in uppercase. `VAR_POP(expr)` Function type: Calculates the population variance of a set of values. `VAR_SAMP(expr)` Function type: Calculates the sample variance of a set of values. `VARIANCE(expr)` Function type: Alias for .