OPAL Functions

Functions compute values for individual columns. This page lists every OPAL function grouped by category.

Aggregate Functions

Aggregate functions are used with aggregating verbs like timechart, aggregate, statsby, and align.

Aggregate functions accept multiple input values from a set of input rows and emit one output value as a single output row. For example, sum calculates the sum of all input numbers, and max returns the largest value.

FunctionDescription
anyAggregate and window function that returns one value of its argument from each group (or frame).
any_not_nullAggregate and window function like any, but configured to ignore null input values when selecting a representative.
array_aggReturns an array of concatenated input values.
array_agg_distinctReturns an array of distinct input values.
array_union_aggReturns an array containing the multiset union of input arrays.
avgComputes the arithmetic mean.
countCounts rows or values in a group (or window frame).
count_distinctEstimate the approximate number of distinct values in the input using hyper-log-log.
count_distinct_exactCount the exact number of distinct values in the input using complete enumeration.
countdistinctDeprecated alias of count_distinct.
countdistinctexactDeprecated alias of count_distinct_exact.
deltaCalculates the value difference of the argument in each time bin for each group.
delta_monotonicCalculates the amount of difference in a column in each time bin for each group.
derivCalculate the average per-second derivative of the argument across the group.
firstfirst returns the value of its expression from the chronologically or otherwise first row in each aggregation group according to
first_not_nullfirst_not_null has the same arguments and aggregate versus window rules as first, but it
hash_aggReturns an aggregate signed 64-bit hash value over the (unordered) set of input rows.
hash_agg_distinctReturns an aggregate signed 64-bit hash value over the (unordered) set of distinct input rows.
histogram_combineAggregates many histogram-like values in each time-aligned group into one combined value of the same representation.
lastlast returns the value of its column from the last row in each aggregation group under the ordering that applies to that
last_not_nullReturn the last non-null value of one column across an ordered group.
maxReturns the maximum of comparable storable values.
medianmedian(expression) is shorthand for an approximate 0.
median_exactmedian_exact(expression) computes the continuous median at p equals 0.
medianexactDeprecated alias of median_exact.
minReturns the minimum of comparable storable values.
object_aggExtract aggregated fields and values from a group of rows into a new JSON object.
otel_exponential_histogram_sumAggregate merge for OpenTelemetry exponential histogram objects, summing scaled counts across inputs in each aggregate group and
otel_histogram_sumWindow or aggregate-time merge of OpenTelemetry classic histogram objects: it sums bucket counts and related fields across grouped
percentilepercentile(expression, p) computes an approximate percentile of expression over each group, where p is a compile-time constant
percentile_contpercentile_cont(expression, p) computes the continuous percentile of expression at fraction p between 0 and 1, using interpolation
percentile_discpercentile_disc(expression, p) returns one of the non-null input values from expression at the discrete rank implied by p between
percentilecontDeprecated alias of percentile_cont.
percentilediscDeprecated alias of percentile_disc.
prom_quantileprom_quantile(prom_bucket, quantile, optional le_val) estimates a Prometheus-style histogram quantile from cumulative bucket
rateComputes an average per-second rate from a numeric or duration series over each aggregation frame.
stddevComputes the standard deviation of a numeric-or-duration column across each group (or window frame).
string_aggReturns concatenated input values, separated by the delimiter.
string_agg_distinctReturns concatenated input values, separated by the delimiter.
sumSums numeric values or durations.
tdigest_aggBuilds a tdigest state from many numeric or duration samples in each aggregate window.
tdigest_combineMerges multiple tdigest states inside each aggregate group, returning a digest of the same generic type as the input column.
topk_aggApproximate aggregate (and window) that collects the top k most frequent values of an expression per group.

Boolean Functions

Boolean functions calculate logic results, involving "true" and "false." Note that a null value is neither true nor false; passing a null value to the verb filter will not emit that row in its output.

FunctionDescription
array_containsTests if an array contains a value.
arrays_overlapCompares whether two arrays have at least one element in common.
boolCasts the argument to bool.
bool_nullReturns a null value of type bool.
containsReturns true if the str string contains the expr string (case-sensitive).
ends_withReturns true if string str ends with string expr.
endswithDeprecated alias of ends_with.
eqReturn true if A is equal to B.
gtReturns true when the first argument is strictly greater than the second, after the compiler applies numeric promotion and other
gteReturns true when the first argument is greater than or equal to the second, after automatic coercion between the operands when
inReturns true when the first expression equals at least one of the following expressions, all of which must be the same type class
ipv4_address_in_networkTest whether an IPv4 address is in a given subnet.
is_nullReturn true if the argument has the null value.
isnullDeprecated alias of is_null.
likeReturns true if subject matches pattern (case-sensitive).
ltReturns true when the first argument is strictly less than the second, after coercion so both operands share a comparable type
lteReturns true when the first argument is less than or equal to the second, using the same coercion and comparability rules as the
match_regexReturn true if the argument input string or object (converted to a string) matches the argument regular expression.
neReturns true when both storable operands are non-null and not equal after the compiler's allowed coercions, and false when they
path_existsGiven a column and path, return whether the JSON path exists in that column.
regex_matchDeprecated alias of match_regex.
sameReturn true if A is the same as B.
searchReturns true when every supplied search term appears in the haystack, using case-insensitive substring matching.
starts_withReturns true if string starts with expr.
startswithDeprecated alias of starts_with.

Misc Functions

Miscellaneous functions are those that do not fit in the other categories.

FunctionDescription
any_nullDeprecated alias of variant_null.
ascSpecify the ordering as ascending when processing data.
coalesceReturn the first non-null argument or null if all are null.
descSpecify the ordering as descending when processing data.
exponential_histogram_nullCreates a null value of type otelExponentialHistogram.
float64Casts the argument to float64.
frameSpecify the approximate relative time frame for a window context.
frame_exactSpecify the exact relative time frame for a window context.
frame_followingSpecifies a cumulative time frame for a window context, where the frame is the current row through the end of the query frame.
frame_precedingSpecifies a cumulative time frame for a window context, where the frame is all the rows from the beginning of the current query
hashAccepts a variable number of arguments of arbitrary types and returns a signed 64-bit hash of the values.
histogram_nullCreates a null value of type otelHistogram.
histogram_quantileReturns an approximate quantile of a histogram-like value as float64.
ifTest if a condition is true or false.
if_nullReturn the second argument if the first argument has the null value.
ifnullDeprecated alias of if_null.
int64Casts the argument to int64.
m_exponential_histogramSelects a metric that must be an OpenTelemetry exponential histogram (object representation) inside align.
m_histogramSelects a metric that must be an OpenTelemetry-style classic histogram (object representation) inside align.
m_tdigestSelects a tdigest-valued metric inside align the same way m selects floats, but requires the chosen
nullsfirstSpecify the ordering as nulls first when processing data.
nullslastSpecify the ordering as nulls last when processing data.
numeric_nullReturns a null value of type numeric.
onon is a special function used to specify the join condition for some join verbs.
order_byCombines one or more column orderings into a single ordering value for verbs and ordered aggregates.
orderbyDeprecated alias of order_by.
parse_hexParses a string encoded hex number and returns an int64.
parsehexDeprecated alias of parse_hex.
strlenReturns the number of Unicode code points in the string (character count rather than UTF-8 byte length).
tdigestConvert a JSON string, an object, or a variant to tdigest, if possible.
tdigest_nullReturns a null value of type tdigest.
variant_nullReturns a null value of type variant.

Networking Functions

Networking related functions are helpful when analyzing networking data. They generally work on network addresses provided in string format, such as "10.0.0.1/8"

FunctionDescription
int64_to_ipv4Converts integer-encoded IPv4 addresses to dotted-quad notation.
ipv4Converts value to the ipv4 type.
ipv4_address_in_networkTest whether an IPv4 address is in a given subnet.
ipv4_network_int64Converts IPv4 network addresses to integer representation.
ipv4_to_int64Given an IPv4 address string in dotted-quad format, convert the address to an integer representing the address.
parse_ipParse an IPv4 or IPv6 network address into relevant attributes.
parseipDeprecated alias of parse_ip.

Numeric Functions

Numeric functions act on and/or produce numeric values, for your mathematical calculation needs.

FunctionDescription
absReturns the absolute value of 'val'.
arccos_degComputes the arc cosine of the input.
arccos_radComputes the arc cosine of the input.
arcsin_degComputes the arc sine of the input.
arcsin_radComputes the arc sine of the input.
arctan_degComputes the arc tangent of the input.
arctan_radComputes the arc tangent of the input.
avgComputes the arithmetic mean.
ceilComputes the ceiling of numeric val at a configurable decimal scale.
cos_degComputes the cosine of the input and returns a float64.
cos_radComputes the cosine of the input and returns a float64.
countCounts rows or values in a group (or window frame).
degreesConverts from radians to degrees.
deltaCalculates the value difference of the argument in each time bin for each group.
delta_monotonicCalculates the amount of difference in a column in each time bin for each group.
dense_rankReturns the dense rank within an ordered group of values.
denserankDeprecated alias of dense_rank.
derivCalculate the average per-second derivative of the argument across the group.
ewmaCalculates the exponentially weighted moving average of a value.
expReturns Euler's number e raised to the given number.
float64_nullReturns a null value of type float64.
floorComputes the floor of numeric val at a configurable decimal scale.
haversine_distance_kmComputes the great circle approximate distance between two latitude/longitude coordinates, using the haversine formula.
int64_nullReturns a null value of type int64.
int_divReturns the integer quotient of the dividend divided by the divisor and truncates the remainder.
lnReturns natural logarithm of a numeric expression.
logReturns logarithm of a numeric expression (second argument) with the provided base (first argument).
medianmedian(expression) is shorthand for an approximate 0.
median_exactmedian_exact(expression) computes the continuous median at p equals 0.
medianexactDeprecated alias of median_exact.
modReturns the int64 remainder after dividing dividend by divisor (the sign of the result follows the dividend, consistent with
percentilepercentile(expression, p) computes an approximate percentile of expression over each group, where p is a compile-time constant
percentile_contpercentile_cont(expression, p) computes the continuous percentile of expression at fraction p between 0 and 1, using interpolation
percentile_discpercentile_disc(expression, p) returns one of the non-null input values from expression at the discrete rank implied by p between
percentilecontDeprecated alias of percentile_cont.
percentilediscDeprecated alias of percentile_disc.
piReturns the value of pi as a float64.
powRaises numeric base to numeric exponent and returns a float64.
prom_quantileprom_quantile(prom_bucket, quantile, optional le_val) estimates a Prometheus-style histogram quantile from cumulative bucket
radiansConverts from degrees to radians.
rankrank() assigns int64 ranks within a window partition based on the window ordering, giving tied rows the same rank and leaving gaps
rateComputes an average per-second rate from a numeric or duration series over each aggregation frame.
roundRounds numeric val to the nearest representable value at a configurable decimal scale.
row_numberrow_number() returns a unique int64 index from 1 up within each window partition in deterministic order given the window ordering
rownumberDeprecated alias of row_number.
sin_degComputes the sine of the input and returns a float64.
sin_radComputes the sine of the input and returns a float64.
sqrtReturns the square root for a given input and null if input is negative.
stddevComputes the standard deviation of a numeric-or-duration column across each group (or window frame).
sumSums numeric values or durations.
tan_degComputes the tangent of the input and returns a float64.
tan_radComputes the tangent of the input and returns a float64.
uniformSamples a pseudo-random value uniformly from the inclusive range between compile-time constant bounds min and max.
width_bucketConstruct equi-width histogram by dividing up the range between min and max with num_buckets buckets, and compute an integer
zipfReturns a Zipf-distributed integer, for N elements and characteristic exponent s.

Regex Functions

Regular expression functions use regular expressions as input.

Regular expressions in Observe must be compile time constants -- they cannot be compiled based on data received from data streams.

Observe uses the POSIX flavor of the regular expression language, which is standard in data storage and processing. For more information, see:

FunctionDescription
count_regex_matchesReturns the number of times the given regular expression pattern occurs in the argument string.
get_regexReturns a string that matches the given regular expression if a match exists.
get_regex_allReturns an array containing all parts of the argument string that match the given regular expression (which may be empty if
match_regexReturn true if the argument input string or object (converted to a string) matches the argument regular expression.
match_regex_allDeprecated alias of get_regex_all.
regexBuilds a value of type regex from a string expression.
regex_matchDeprecated alias of match_regex.
regex_replaceDeprecated alias of replace_regex.
replace_regexReplaces all instances of a matched regex pattern in the input string with a provided value.

Semistructured Functions

Semistructured functions act upon, or produce, arrays or objects that are treated as scalars. E.g., a single column may contain multiple values in an array, or multiple key/value tuples in an object.

The values inside semi-structured containers are stored as variants, and must be cast to the type you expect them to have. If the array or object contains a value of an unexpected type, the cast returns null.

FunctionDescription
append_itemReturns an array containing all elements from the source array as well as the new element.
arrayConvert a datum into an array or NULL if conversion is impossible
array_aggReturns an array of concatenated input values.
array_agg_distinctReturns an array of distinct input values.
array_containsTests if an array contains a value.
array_distinctReturns a new array that contains only the distinct elements from the input array after removing duplicate elements.
array_lengthreturns the number of elements in an array, or null if input is not an array
array_maxReturn the maximum value in an array.
array_minReturn the minimum value in an array.
array_nullReturns a null value of type array.
array_pivotDeprecated alias of pivot_array.
array_to_stringCast all values in an array to string and concatenate them, optionally adding a separator between each value.
array_union_aggReturns an array containing the multiset union of input arrays.
array_unpivotDeprecated alias of unpivot_array.
arrays_overlapCompares whether two arrays have at least one element in common.
concat_arraysReturns a concatenation of N arrays array1, array2, arrayN.
detect_browserIdentify the browser used for a web request from its User-Agent header.
drop_fieldsDrop one or more fields from an object.
embed_sql_paramsEmbed parameters into the given prepared SQL statement by replacing occurrences of the placeholder character '?
get_fieldGiven an object, and a computed string value as key (which can be a column value or some string concatenation, for example), look
get_itemGiven an array and a computed index, return the item at that index in the array.
get_jmespathProcess an object or array expression using a query written in the JMESPath query language.
get_regex_allReturns an array containing all parts of the argument string that match the given regular expression (which may be empty if
index_of_itemGiven an array and a value, return the index of the first occurrence of that value within that array, or NULL if the value isn't
insert_itemReturns an array containing all elements from the source array as well as the new element.
intersect_arraysReturns an array containing the matching elements inside the two input arrays.
m_objectSelect a metric with an object typed value for the align verb.
make_arrayReturns an array constructed from zero, one or more input arguments.
make_array_rangeBuilds an array<int64> of consecutive integers starting at start (inclusive) and ending before end (exclusive), stepping by
make_fieldsExtend an existing object with new fields.
make_objectTurn a sequence of name:value elements into an object.
makeobjectDeprecated alias of make_object.
match_regex_allDeprecated alias of get_regex_all.
merge_objectsMerge one or more objects into a single object.
objectConvert a datum into an object or NULL if conversion is impossible
object_aggExtract aggregated fields and values from a group of rows into a new JSON object.
object_keysGet an array of top-level keys from an object type field (field names from JSON objects).
object_nullReturns a null value of type object.
otel_exponential_histogram_quantileEstimates a population quantile from an OpenTelemetry exponential histogram encoded as an object.
otel_exponential_histogram_sumAggregate merge for OpenTelemetry exponential histogram objects, summing scaled counts across inputs in each aggregate group and
otel_histogram_quantileEstimates a population quantile from an OpenTelemetry classic histogram encoded as an object.
otel_histogram_sumWindow or aggregate-time merge of OpenTelemetry classic histogram objects: it sums bucket counts and related fields across grouped
parse_csvParses an input string as character-separated values, where the default separator is a comma (comma-separated values.
parse_ipParse an IPv4 or IPv6 network address into relevant attributes.
parse_jsonParse the argument value as a JSON string.
parse_kvsReturns an object of key=value pairs extracted from an input string.
parse_urlParses arg as an absolute URL and returns an object whose fields mirror the Snowflake PARSE_URL result, with percent
parseipDeprecated alias of parse_ip.
parsejsonDeprecated alias of parse_json.
parsekvsDeprecated alias of parse_kvs.
parseurlDeprecated alias of parse_url.
path_existsGiven a column and path, return whether the JSON path exists in that column.
pick_fieldsPick one or more fields from an object.
pivot_arrayConverts an array of "key"-"value" pairs into an object with key-value attributes.
prepend_itemReturns an array containing all elements from the source array as well as the new element.
slice_arrayGiven an array, returns a possibly smaller array, starting at the given from index, and including items up to *but not
sort_arrayReturn an array with the elements of the input array in sorted order.
splitSplits the string into an array, based on the separator.
tokenizeSplits the string into an array based on separator, which is treated as a set of characters.
topk_aggApproximate aggregate (and window) that collects the top k most frequent values of an expression per group.
unpivot_arrayunpivot_array expands one object value into an array of object rows: each top-level key produces a row whose

Special Functions

Special functions implement flow control-like structures or other control semantics.

FunctionDescription
caseReturn a matching result if any of the multiple given conditions are true.
group_byDeclares grouping columns and optional grouping expressions for aggregate and window stages.
groupbyDeprecated alias of group_by.
mSelects one scalar float64 metric series inside the align verb by metric name, pivoting the narrow metric table so
metricSelect the metrics in the rollup verb.
optionsSpecify options to change the verb's behavior
pkAlias of primary_key.
primary_keySpecify the primary key for some verbs
primarykeyDeprecated alias of primary_key.
tagsUsed to specify tags to publish a metric dataset.
valid_forSpecify the validity period for each event for some verbs
validforDeprecated alias of valid_for.
windowEvaluate OPAL within time windows.

String Functions

String functions process strings as input, or provide strings as output.

FunctionDescription
array_pivotDeprecated alias of pivot_array.
array_to_stringCast all values in an array to string and concatenate them, optionally adding a separator between each value.
array_unpivotDeprecated alias of unpivot_array.
check_jsoncheck_json validates that a string holds JSON.
concat_stringsReturn the concatenation of all string arguments.
containsReturns true if the str string contains the expr string (case-sensitive).
decode_base64Decodes a Base64-encoded string into binary data represented as a UTF-8 string.
decode_uriReplace %-encoded escape sequences in a string with unencoded plain text.
decode_uri_componentReplace all %-encoded escape sequences in a string with unencoded plain text.
decodebase64Deprecated alias of decode_base64.
detect_browserIdentify the browser used for a web request from its User-Agent header.
editdistanceReturns the Levenshtein distance between str1 and str2.
embed_sql_paramsEmbed parameters into the given prepared SQL statement by replacing occurrences of the placeholder character '?
encode_base64EncodeBase64 encodes the input in the base64 format
encode_uriReplace certain characters in a string with %-encoded escape sequences.
encode_uri_componentReplace certain characters in a string with %-encoded escape sequences.
encodebase64Deprecated alias of encode_base64.
ends_withReturns true if string str ends with string expr.
endswithDeprecated alias of ends_with.
format_timeFormat a timestamp column according to the specified format string.
get_regexReturns a string that matches the given regular expression if a match exists.
int64_to_ipv4Converts integer-encoded IPv4 addresses to dotted-quad notation.
ipv4_address_in_networkTest whether an IPv4 address is in a given subnet.
labelReturns the display string label for a labeled reference value.
leftReturns the leftmost length Unicode characters of value.
likeReturns true if subject matches pattern (case-sensitive).
lowerReturn the input string in lowercase.
lpadLeft-pads a string to a target length counted in Unicode scalar values (runes), repeating an optional pad string that defaults to
ltrimltrim removes leading characters from a string.
parse_csvParses an input string as character-separated values, where the default separator is a comma (comma-separated values.
parse_kvsReturns an object of key=value pairs extracted from an input string.
parse_timestampParse a string value, whose format is specified by the format argument, as a timestamp.
parsekvsDeprecated alias of parse_kvs.
pivot_arrayConverts an array of "key"-"value" pairs into an object with key-value attributes.
positionReturns the zero-based index of the first occurrence of needle inside haystack, or -1 when there is no match.
regexBuilds a value of type regex from a string expression.
regex_replaceDeprecated alias of replace_regex.
replaceReturns value with every occurrence of substring replaced by replacement, using non-overlapping whole-substring matches
replace_regexReplaces all instances of a matched regex pattern in the input string with a provided value.
rightReturns the rightmost length Unicode characters of value.
rpadRight-pads a string to a target length counted in Unicode scalar values (runes), repeating an optional pad string that defaults to
rtrimrtrim removes trailing characters from a string.
sha2Returns a hex-encoded string containing the N-bit SHA-2 message digest, where N is the specified output digest size.
splitSplits the string into an array, based on the separator.
split_partSplits a given string at a specified delimiter character and returns the requested part.
starts_withReturns true if string starts with expr.
startswithDeprecated alias of starts_with.
strcatDeprecated alias of concat_strings.
stringProduces a string from the argument.
string_aggReturns concatenated input values, separated by the delimiter.
string_agg_distinctReturns concatenated input values, separated by the delimiter.
string_concatDeprecated alias of concat_strings.
string_nullReturns a null value of type string.
substringReturns a contiguous slice of a string.
tokenizeSplits the string into an array based on separator, which is treated as a set of characters.
tokenize_partTokenizes the input string using the delimiter and returns the requested part.
trimtrim removes leading and trailing characters from a string.
unpivot_arrayunpivot_array expands one object value into an array of object rows: each top-level key produces a row whose
upperReturn the input string in uppercase.
variant_type_nameResolves the data type of a variant column so that column may be typed for better performance.

Time Functions

Time functions provide conversion to and from various time and date formats.

FunctionDescription
absReturns the absolute value of 'val'.
avgComputes the arithmetic mean.
bin_end_timeReturns the end time of the current bin (exclusive).
bin_sizeReturns the size of the time bin that's being aggregated.
bin_start_timeReturns the start time of the current bin (inclusive).
deltaCalculates the value difference of the argument in each time bin for each group.
delta_monotonicCalculates the amount of difference in a column in each time bin for each group.
derivCalculate the average per-second derivative of the argument across the group.
durationConvert one argument as a number of nanoseconds or a timestamp, or two arguments as start or stop timestamps, to a duration.
duration_hrThe input is a number representing a number of hours, the output is that quantity as type duration.
duration_minThe input is a number representing a number of minutes, the output is that quantity as type duration.
duration_msThe input is a number representing a number of milliseconds, the output is that quantity as type duration.
duration_nullReturns a null value of type duration.
duration_secThe input is a number representing a number of seconds, the output is that quantity as type duration.
ewmaCalculates the exponentially weighted moving average of a value.
format_timeFormat a timestamp column according to the specified format string.
from_millisecondsGiven a numeric value representing milliseconds since epoch, return a timestamp of that point in time.
from_nanosecondsBuilds a timestamp from a numeric value interpreted as nanoseconds since the Unix epoch.
from_secondsGiven a numeric value representing seconds since epoch, return a timestamp of that point in time.
histogram_fractionEvaluates the cumulative distribution at a fixed threshold: it returns the approximate fraction of the distribution less than or
medianmedian(expression) is shorthand for an approximate 0.
median_exactmedian_exact(expression) computes the continuous median at p equals 0.
medianexactDeprecated alias of median_exact.
millisecondsDeprecated alias of from_milliseconds.
nanosecondsDeprecated alias of from_nanoseconds.
nowReturns the current time for which the query is executed as timestamp.
parse_durationGiven a string describing the duration between two points in time, convert it to a duration.
parse_isotimeParse an ISO8601 (YYYY-MM-DDTHH:MM:SSZ) formatted string as a timestamp.
parse_timestampParse a string value, whose format is specified by the format argument, as a timestamp.
parseisotimeDeprecated alias of parse_isotime.
percentilepercentile(expression, p) computes an approximate percentile of expression over each group, where p is a compile-time constant
percentile_contpercentile_cont(expression, p) computes the continuous percentile of expression at fraction p between 0 and 1, using interpolation
percentile_discpercentile_disc(expression, p) returns one of the non-null input values from expression at the discrete rank implied by p between
percentilecontDeprecated alias of percentile_cont.
percentilediscDeprecated alias of percentile_disc.
query_end_timeReturns the latest time of the query time window.
query_start_timeReturns the earliest time of the query time window.
queryendtimeDeprecated alias of query_end_time.
querystarttimeDeprecated alias of query_start_time.
rateComputes an average per-second rate from a numeric or duration series over each aggregation frame.
row_end_timeReturns the value of the "Valid To" column, or null if the verb input dataset has no "Valid To" column.
row_endtimeDeprecated alias of row_end_time.
row_start_timeAlias of row_timestamp.
row_timestampReturns the value of the timestamp column for each row.
secondsDeprecated alias of from_seconds.
stddevComputes the standard deviation of a numeric-or-duration column across each group (or window frame).
sumSums numeric values or durations.
tdigest_aggBuilds a tdigest state from many numeric or duration samples in each aggregate window.
tdigest_quantileEstimates the value at a requested probability from a tdigest column.
timestamp_msAlias of from_milliseconds.
timestamp_nsAlias of from_nanoseconds.
timestamp_nullReturns a null value of type timestamp.
timestamp_sAlias of from_seconds.
to_daysConvert a duration to a number of days.
to_hoursConvert a duration to a number of hours.
to_millisecondsConvert a duration to a number of milliseconds.
to_minutesConvert a duration to a number of minutes.
to_nanosecondsConvert a duration to a number of nanoseconds.
to_secondsConvert a duration to a number of seconds.
to_weeksConvert a duration to a number of weeks.
valid_forSpecify the validity period for each event for some verbs
validforDeprecated alias of valid_for.

Window Functions

Window functions are like aggregate functions in that they summarize input values from multiple input rows. However, each input row generates a corresponding output value, with the window potentially sliding along the list of rows.

For example, a "trailing 5 minute average" function uses a window back for 5 minutes and produce one output row per input row. But each output row looks back across many input rows in history.

FunctionDescription
anyAggregate and window function that returns one value of its argument from each group (or frame).
any_not_nullAggregate and window function like any, but configured to ignore null input values when selecting a representative.
array_union_aggReturns an array containing the multiset union of input arrays.
avgComputes the arithmetic mean.
countCounts rows or values in a group (or window frame).
count_distinctEstimate the approximate number of distinct values in the input using hyper-log-log.
count_distinct_exactCount the exact number of distinct values in the input using complete enumeration.
countdistinctDeprecated alias of count_distinct.
countdistinctexactDeprecated alias of count_distinct_exact.
deltaCalculates the value difference of the argument in each time bin for each group.
delta_monotonicCalculates the amount of difference in a column in each time bin for each group.
dense_rankReturns the dense rank within an ordered group of values.
denserankDeprecated alias of dense_rank.
derivCalculate the average per-second derivative of the argument across the group.
ewmaCalculates the exponentially weighted moving average of a value.
firstfirst returns the value of its expression from the chronologically or otherwise first row in each aggregation group according to
first_not_nullfirst_not_null has the same arguments and aggregate versus window rules as first, but it
hash_aggReturns an aggregate signed 64-bit hash value over the (unordered) set of input rows.
hash_agg_distinctReturns an aggregate signed 64-bit hash value over the (unordered) set of distinct input rows.
laglag(value, lagby) returns the value expression evaluated on the row found lagby physical rows earlier in the current window
lag_not_nullReturn the non-null value of one column in a previous row across an ordered group.
lastlast returns the value of its column from the last row in each aggregation group under the ordering that applies to that
last_not_nullReturn the last non-null value of one column across an ordered group.
leadlead(value, leadby) returns value from the row found leadby rows later in the window partition order, where leadby is a non
lead_not_nullReturn the non-null value of one column in a following row across an ordered group.
maxReturns the maximum of comparable storable values.
medianmedian(expression) is shorthand for an approximate 0.
median_exactmedian_exact(expression) computes the continuous median at p equals 0.
medianexactDeprecated alias of median_exact.
minReturns the minimum of comparable storable values.
object_aggExtract aggregated fields and values from a group of rows into a new JSON object.
percentilepercentile(expression, p) computes an approximate percentile of expression over each group, where p is a compile-time constant
percentile_contpercentile_cont(expression, p) computes the continuous percentile of expression at fraction p between 0 and 1, using interpolation
percentile_discpercentile_disc(expression, p) returns one of the non-null input values from expression at the discrete rank implied by p between
percentilecontDeprecated alias of percentile_cont.
percentilediscDeprecated alias of percentile_disc.
rankrank() assigns int64 ranks within a window partition based on the window ordering, giving tied rows the same rank and leaving gaps
rateComputes an average per-second rate from a numeric or duration series over each aggregation frame.
row_numberrow_number() returns a unique int64 index from 1 up within each window partition in deterministic order given the window ordering
rownumberDeprecated alias of row_number.
stddevComputes the standard deviation of a numeric-or-duration column across each group (or window frame).
sumSums numeric values or durations.
tdigest_aggBuilds a tdigest state from many numeric or duration samples in each aggregate window.
tdigest_combineMerges multiple tdigest states inside each aggregate group, returning a digest of the same generic type as the input column.
topk_aggApproximate aggregate (and window) that collects the top k most frequent values of an expression per group.