Aggregate Functions
approx_distinct
Returns the approximate number of distinct input values. This function provides an approximation of count(DISTINCT x). Zero is returned if all input values are null.
Supported Signatures
approx_most_frequent
Computes the top frequent values up to buckets elements approximately. Approximate estimation of the function enables us to pick up the frequent values with less memory. Larger capacity improves the accuracy of underlying algorithm with sacrificing the memory capacity. The returned value is a map containing the top elements with corresponding estimated frequency.
Supported Signatures
approx_percentile
Returns the approximate percentile for all input values of x at the given percentage. The value of percentage must be between zero and one and must be constant for all input rows.
Supported Signatures
arbitrary
Returns an arbitrary non-null value of x, if one exists. Identical to any_value().
Supported Signatures
array_agg
Returns an array created from the input x elements.
Examples:
Supported Signatures
avg
Returns the average (arithmetic mean) of all input values.
Examples:
Supported Signatures
bitwise_and_agg
Returns the bitwise AND of all input non-NULL values in 2βs complement representation. If all records inside the group are NULL, or if the group is empty, the function returns NULL.
Supported Signatures
bitwise_or_agg
Returns the bitwise OR of all input non-NULL values in 2βs complement representation. If all records inside the group are NULL, or if the group is empty, the function returns NULL.
Supported Signatures
bool_and
Returns TRUE if every input value is TRUE, otherwise FALSE.
Supported Signatures
bool_or
Returns TRUE if any input value is TRUE, otherwise FALSE.
Supported Signatures
checksum
Returns an order-insensitive checksum of the given values.
Supported Signatures
corr
Returns correlation coefficient of input values.
Supported Signatures
count
Returns the number of input rows.
Examples:
Supported Signatures
count_if
Returns the number of TRUE input values. This function is equivalent to count(CASE WHEN x THEN 1 END).
Supported Signatures
covar_pop
Returns the population covariance of input values.
Supported Signatures
covar_samp
Returns the sample covariance of input values.
Supported Signatures
every
This is an alias for bool_and().
Supported Signatures
geometric_mean
Returns the geometric mean of all input values.
Supported Signatures
histogram
Returns a map containing the count of the number of times each input value occurs.
Supported Signatures
kurtosis
Returns the excess kurtosis of all input values. Unbiased estimate using the following expression.
Supported Signatures
listagg
Returns the concatenated input values, separated by the separator string.
Supported Signatures
map_agg
Returns a map created from the input key / value pairs.
Supported Signatures
map_union
Returns the union of all the input maps. If a key is found in multiple input maps, that keyβs value in the resulting map comes from an arbitrary input map.
Supported Signatures
max
Returns the maximum value of all input values.
Supported Signatures
max_by
Returns the value of x associated with the maximum value of y over all input values.
Supported Signatures
min
Returns the minimum value of all input values.
Supported Signatures
min_by
Returns the value of x associated with the minimum value of y over all input values.
Supported Signatures
multimap_agg
Returns a multimap created from the input key / value pairs. Each key can be associated with multiple values.
Supported Signatures
numeric_histogram
Computes an approximate histogram with up to buckets number of buckets for all values with a per-item weight of weight. The algorithm is based loosely on.
Supported Signatures
regr_intercept
Returns linear regression intercept of input values. y is the dependent value. x is the independent value.
Supported Signatures
regr_slope
Returns linear regression slope of input values. y is the dependent value. x is the independent value.
Supported Signatures
skewness
Returns the Fisherβs moment coefficient of skewness of all input values.
Supported Signatures
stddev
This is an alias for stddev_samp().
Supported Signatures
stddev_pop
Returns the population standard deviation of all input values.
Examples:
Supported Signatures
stddev_samp
Returns the sample standard deviation of all input values.
Examples:
Supported Signatures
sum
Returns the sum of all input values.
Examples:
Supported Signatures
var_pop
Returns the population variance of all input values.
Supported Signatures
var_samp
Returns the sample variance of all input values.
Supported Signatures
variance
This is an alias for var_samp().
Supported Signatures