Class AggregateFunction
-
Method Summary
Modifier and TypeMethodDescriptionstatic AggregateFunctionarrayAgg(Expression expression) Creates an aggregation that collects all values of an expression across multiple stage inputs into an array.static AggregateFunctionCreates an aggregation that collects all values of a field across multiple stage inputs into an array.static AggregateFunctionarrayAggDistinct(Expression expression) Creates an aggregation that collects all distinct values of an expression across multiple stage inputs into an array.static AggregateFunctionarrayAggDistinct(String fieldName) Creates an aggregation that collects all distinct values of a field across multiple stage inputs into an array.Assigns an alias to this aggregate.static AggregateFunctionaverage(Expression expression) Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs.static AggregateFunctionCreates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs.static AggregateFunctioncount(Expression expression) Creates an aggregation that counts the number of stage inputs with valid evaluations of the providedexpression.static AggregateFunctionCreates an aggregation that counts the number of stage inputs where the input field exists.static AggregateFunctioncountAll()Creates an aggregation that counts the total number of stage inputs.static AggregateFunctioncountDistinct(Expression expression) Creates an aggregation that counts the number of distinct values of an expression across multiple stage inputs.static AggregateFunctioncountDistinct(String fieldName) Creates an aggregation that counts the number of distinct values of a field across multiple stage inputs.static AggregateFunctioncountIf(BooleanExpression condition) Creates an aggregation that counts the number of stage inputs where the provided boolean expression evaluates to true.static AggregateFunctionfirst(Expression expression) Creates an aggregation that finds the first value of an expression across multiple stage inputs.static AggregateFunctionCreates an aggregation that finds the first value of a field across multiple stage inputs.static AggregateFunctionlast(Expression expression) Creates an aggregation that finds the last value of an expression across multiple stage inputs.static AggregateFunctionCreates an aggregation that finds the last value of a field across multiple stage inputs.static AggregateFunctionmaximum(Expression expression) Creates an aggregation that finds the maximum value of an expression across multiple stage inputs.static AggregateFunctionCreates an aggregation that finds the maximum value of a field across multiple stage inputs.static AggregateFunctionminimum(Expression expression) Creates an aggregation that finds the minimum value of an expression across multiple stage inputs.static AggregateFunctionCreates an aggregation that finds the minimum value of a field across multiple stage inputs.static AggregateFunctionrawAggregate(String name, Expression... expr) Creates a raw aggregation function.static AggregateFunctionsum(Expression expression) Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs.static AggregateFunctionCreates an aggregation that calculates the sum of a field's values across multiple stage inputs.
-
Method Details
-
rawAggregate
Creates a raw aggregation function.This method provides a way to call aggregation functions that are supported by the Firestore backend but that are not available as specific factory methods in this class.
- Parameters:
name- The name of the aggregation function.expr- The expressions to pass as arguments to the function.- Returns:
- A new
AggregateFunctionfor the specified function.
-
countAll
Creates an aggregation that counts the total number of stage inputs.- Returns:
- A new
AggregateFunctionrepresenting the countAll aggregation.
-
count
Creates an aggregation that counts the number of stage inputs where the input field exists.- Parameters:
fieldName- The name of the field to count.- Returns:
- A new
AggregateFunctionrepresenting the 'count' aggregation.
-
count
Creates an aggregation that counts the number of stage inputs with valid evaluations of the providedexpression.- Parameters:
expression- The expression to count.- Returns:
- A new
AggregateFunctionrepresenting the 'count' aggregation.
-
countDistinct
Creates an aggregation that counts the number of distinct values of a field across multiple stage inputs.- Parameters:
fieldName- The name of the field to count the distinct values of.- Returns:
- A new
AggregateFunctionrepresenting the count distinct aggregation.
-
countDistinct
Creates an aggregation that counts the number of distinct values of an expression across multiple stage inputs.- Parameters:
expression- The expression to count the distinct values of.- Returns:
- A new
AggregateFunctionrepresenting the count distinct aggregation.
-
countIf
Creates an aggregation that counts the number of stage inputs where the provided boolean expression evaluates to true.- Parameters:
condition- The boolean expression to evaluate on each input.- Returns:
- A new
AggregateFunctionrepresenting the count aggregation.
-
sum
Creates an aggregation that calculates the sum of a field's values across multiple stage inputs.- Parameters:
fieldName- The name of the field containing numeric values to sum up.- Returns:
- A new
AggregateFunctionrepresenting the sum aggregation.
-
sum
Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs.- Parameters:
expression- The expression to sum up.- Returns:
- A new
AggregateFunctionrepresenting the sum aggregation.
-
average
Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs.- Parameters:
fieldName- The name of the field containing numeric values to average.- Returns:
- A new
AggregateFunctionrepresenting the average aggregation.
-
average
Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs.- Parameters:
expression- The expression representing the values to average.- Returns:
- A new
AggregateFunctionrepresenting the average aggregation.
-
minimum
Creates an aggregation that finds the minimum value of a field across multiple stage inputs.- Parameters:
fieldName- The name of the field to find the minimum value of.- Returns:
- A new
AggregateFunctionrepresenting the minimum aggregation.
-
minimum
Creates an aggregation that finds the minimum value of an expression across multiple stage inputs.- Parameters:
expression- The expression to find the minimum value of.- Returns:
- A new
AggregateFunctionrepresenting the minimum aggregation.
-
maximum
Creates an aggregation that finds the maximum value of a field across multiple stage inputs.- Parameters:
fieldName- The name of the field to find the maximum value of.- Returns:
- A new
AggregateFunctionrepresenting the maximum aggregation.
-
maximum
Creates an aggregation that finds the maximum value of an expression across multiple stage inputs.- Parameters:
expression- The expression to find the maximum value of.- Returns:
- A new
AggregateFunctionrepresenting the maximum aggregation.
-
first
Creates an aggregation that finds the first value of a field across multiple stage inputs.- Parameters:
fieldName- The name of the field to find the first value of.- Returns:
- A new
AggregateFunctionrepresenting the first aggregation.
-
first
Creates an aggregation that finds the first value of an expression across multiple stage inputs.- Parameters:
expression- The expression to find the first value of.- Returns:
- A new
AggregateFunctionrepresenting the first aggregation.
-
last
Creates an aggregation that finds the last value of a field across multiple stage inputs.- Parameters:
fieldName- The name of the field to find the last value of.- Returns:
- A new
AggregateFunctionrepresenting the last aggregation.
-
last
Creates an aggregation that finds the last value of an expression across multiple stage inputs.- Parameters:
expression- The expression to find the last value of.- Returns:
- A new
AggregateFunctionrepresenting the last aggregation.
-
arrayAgg
Creates an aggregation that collects all values of a field across multiple stage inputs into an array.If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.
- Parameters:
fieldName- The name of the field to collect values from.- Returns:
- A new
AggregateFunctionrepresenting the array_agg aggregation.
-
arrayAgg
Creates an aggregation that collects all values of an expression across multiple stage inputs into an array.If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.
- Parameters:
expression- The expression to collect values from.- Returns:
- A new
AggregateFunctionrepresenting the array_agg aggregation.
-
arrayAggDistinct
Creates an aggregation that collects all distinct values of a field across multiple stage inputs into an array.If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.
- Parameters:
fieldName- The name of the field to collect values from.- Returns:
- A new
AggregateFunctionrepresenting the array_agg_distinct aggregation.
-
arrayAggDistinct
Creates an aggregation that collects all distinct values of an expression across multiple stage inputs into an array.If the expression resolves to an absent value, it is converted to `null`. The order of elements in the output array is not stable and shouldn't be relied upon.
- Parameters:
expression- The expression to collect values from.- Returns:
- A new
AggregateFunctionrepresenting the array_agg_distinct aggregation.
-
as
Assigns an alias to this aggregate.- Parameters:
alias- The alias to assign to this aggregate.- Returns:
- A new
AliasedAggregatethat wraps this aggregate and associates it with the provided alias.
-