Interface SqlAggregator

All Known Implementing Classes:
ApproxCountDistinctSqlAggregator, ArrayConcatSqlAggregator, ArraySqlAggregator, AvgSqlAggregator, BitwiseSqlAggregator, BuiltinApproxCountDistinctSqlAggregator, CountSqlAggregator, EarliestLatestAnySqlAggregator, EarliestLatestBySqlAggregator, GroupingSqlAggregator, LiteralSqlAggregator, MaxSqlAggregator, MinSqlAggregator, SimpleSqlAggregator, SingleValueSqlAggregator, StringSqlAggregator, SumSqlAggregator, SumZeroSqlAggregator, WindowSqlAggregate

public interface SqlAggregator
Bridge between Druid and SQL aggregators.
  • Method Details

    • calciteFunction

      org.apache.calcite.sql.SqlAggFunction calciteFunction()
      Returns the SQL operator corresponding to this aggregation function. Should be a singleton.
      Returns:
      operator
    • toDruidAggregation

      @Nullable default Aggregation toDruidAggregation(PlannerContext plannerContext, VirtualColumnRegistry virtualColumnRegistry, String name, org.apache.calcite.rel.core.AggregateCall aggregateCall, InputAccessor inputAccessor, List<Aggregation> existingAggregations, boolean finalizeAggregations)
      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.
      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
    • toDruidAggregation

      @Nullable default Aggregation toDruidAggregation(PlannerContext plannerContext, RowSignature rowSignature, VirtualColumnRegistry virtualColumnRegistry, org.apache.calcite.rex.RexBuilder rexBuilder, String name, org.apache.calcite.rel.core.AggregateCall aggregateCall, org.apache.calcite.rel.core.Project project, List<Aggregation> existingAggregations, boolean finalizeAggregations)
      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.
      Parameters:
      plannerContext - SQL planner context
      rowSignature - input row signature
      virtualColumnRegistry - re-usable virtual column references
      rexBuilder - a rexBuilder, in case you need one
      name - desired output name of the aggregation
      aggregateCall - aggregate call object
      project - project that should be applied before aggregation; may be null
      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