Skip to main content

execute_aggregate

Function execute_aggregate 

Source
pub async fn execute_aggregate(
    registry: &TableRegistry,
    sources: SourceSpec,
    filter: Option<ListFilter>,
    aggregator: AliasAggregator,
    schema: &SchemaConfig,
) -> Result<AliasRunResult, MiniAppError>
Expand description

Execute a multi-table aggregation request.

Resolves each source table via registry, mounts every backing .db file into a fresh in-memory connection with ATTACH DATABASE, composes a UNION ALL inner sub-query (or a single SELECT for SourceSpec::Single), and wraps it in an outer SELECT <aggregate> (with GROUP BY + optional HAVING for AliasAggregator::GroupBy).

§Crux compliance

  • Crux #1: reuses the existing ListFilter::build_sql via the sibling ListFilter::build_subquery method (no signature change).
  • Crux #2: having is emitted as a literal HAVING clause after GROUP BY, never as WHERE.
  • Crux #3: multi-table sources are combined with literal UNION ALL; JOIN is never emitted and no application-layer merge happens.

§Errors