Class AggregateFunction

java.lang.Object
com.google.cloud.firestore.pipeline.expressions.AggregateFunction

@BetaApi public class AggregateFunction extends Object
A class that represents an aggregate function.
  • Method Details

    • rawAggregate

      @BetaApi public static AggregateFunction rawAggregate(String name, Expression... expr)
      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 AggregateFunction for the specified function.
    • countAll

      @BetaApi public static AggregateFunction countAll()
      Creates an aggregation that counts the total number of stage inputs.
      Returns:
      A new AggregateFunction representing the countAll aggregation.
    • count

      @BetaApi public static AggregateFunction count(String fieldName)
      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 AggregateFunction representing the 'count' aggregation.
    • count

      @BetaApi public static AggregateFunction count(Expression expression)
      Creates an aggregation that counts the number of stage inputs with valid evaluations of the provided expression.
      Parameters:
      expression - The expression to count.
      Returns:
      A new AggregateFunction representing the 'count' aggregation.
    • countDistinct

      @BetaApi public static AggregateFunction countDistinct(String fieldName)
      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 AggregateFunction representing the count distinct aggregation.
    • countDistinct

      @BetaApi public static AggregateFunction countDistinct(Expression expression)
      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 AggregateFunction representing the count distinct aggregation.
    • countIf

      @BetaApi public static AggregateFunction countIf(BooleanExpression condition)
      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 AggregateFunction representing the count aggregation.
    • sum

      @BetaApi public static AggregateFunction sum(String fieldName)
      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 AggregateFunction representing the sum aggregation.
    • sum

      @BetaApi public static AggregateFunction sum(Expression expression)
      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 AggregateFunction representing the sum aggregation.
    • average

      @BetaApi public static AggregateFunction average(String fieldName)
      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 AggregateFunction representing the average aggregation.
    • average

      @BetaApi public static AggregateFunction average(Expression expression)
      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 AggregateFunction representing the average aggregation.
    • minimum

      @BetaApi public static AggregateFunction minimum(String fieldName)
      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 AggregateFunction representing the minimum aggregation.
    • minimum

      @BetaApi public static AggregateFunction minimum(Expression expression)
      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 AggregateFunction representing the minimum aggregation.
    • maximum

      @BetaApi public static AggregateFunction maximum(String fieldName)
      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 AggregateFunction representing the maximum aggregation.
    • maximum

      @BetaApi public static AggregateFunction maximum(Expression expression)
      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 AggregateFunction representing the maximum aggregation.
    • as

      @BetaApi public AliasedAggregate as(String alias)
      Assigns an alias to this aggregate.
      Parameters:
      alias - The alias to assign to this aggregate.
      Returns:
      A new AliasedAggregate that wraps this aggregate and associates it with the provided alias.