Class SimpleSqlAggregator

java.lang.Object
org.apache.druid.sql.calcite.aggregation.builtin.SimpleSqlAggregator
All Implemented Interfaces:
SqlAggregator
Direct Known Subclasses:
MaxSqlAggregator, MinSqlAggregator, SingleValueSqlAggregator, SumSqlAggregator

public abstract class SimpleSqlAggregator extends Object implements SqlAggregator
Abstraction for single column, single argument simple aggregators like sum, avg, min, max that: 1) Can take direct field accesses or expressions as inputs. 2) Cannot implicitly cast strings to numbers when using a direct field access.
See Also:
  • Constructor Details

    • SimpleSqlAggregator

      public SimpleSqlAggregator()
  • Method Details

    • badTypeException

      public static DruidException badTypeException(String columnName, String agg, ColumnType type)
    • toDruidAggregation

      @Nullable public Aggregation toDruidAggregation(PlannerContext plannerContext, VirtualColumnRegistry virtualColumnRegistry, String name, org.apache.calcite.rel.core.AggregateCall aggregateCall, InputAccessor inputAccessor, List<Aggregation> existingAggregations, boolean finalizeAggregations)
      Description copied from interface: SqlAggregator
      Returns a Druid Aggregation corresponding to a SQL AggregateCall. This method should ignore filters; they will be applied to your aggregator in a later step.
      Specified by:
      toDruidAggregation in interface SqlAggregator
      Parameters:
      plannerContext - SQL planner context
      virtualColumnRegistry - re-usable virtual column references
      name - desired output name of the aggregation
      aggregateCall - aggregate call object
      inputAccessor - gives access to input fields and schema
      existingAggregations - existing aggregations for this query; useful for re-using aggregations. May be safely ignored if you do not want to re-use existing aggregations.
      finalizeAggregations - true if this query should include explicit finalization for all of its aggregators, where required. This is set for subqueries where Druid's native query layer does not do this automatically.
      Returns:
      aggregation, or null if the call cannot be translated