You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Konstantin Orlov (Jira)" <ji...@apache.org> on 2024/03/26 13:57:00 UTC
[jira] [Updated] (IGNITE-20009) Sql. Rework 2-phase aggregates part 2. AVG as SUM / COUNT.
[ https://issues.apache.org/jira/browse/IGNITE-20009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Konstantin Orlov updated IGNITE-20009:
--------------------------------------
Fix Version/s: 3.0.0-beta2
> Sql. Rework 2-phase aggregates part 2. AVG as SUM / COUNT.
> ----------------------------------------------------------
>
> Key: IGNITE-20009
> URL: https://issues.apache.org/jira/browse/IGNITE-20009
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Affects Versions: 3.0.0-beta1
> Reporter: Maksim Zhuravkov
> Assignee: Maksim Zhuravkov
> Priority: Minor
> Labels: ignite-3
> Fix For: 3.0.0-beta2
>
> Time Spent: 4h 20m
> Remaining Estimate: 0h
>
> Map/reduce implementation of some aggregates requires replacing an aggregate with a combination of aggregates. For example AVG(col) should be implemented as
> MAP: SUM(col) sum_col, COUNT (col) as count_col
> REDUCE: SUM(sum_col)/SUM(COUNT(count_col))
> To implement AVG for two phase aggregation we need the following changes:
> - Replace AVG on MAP phase with SUM and COUNT.
> - Change rowType produced by MAP phase/accepted by REDUCE phase.
> - Add a projection after a reduce aggregate that includes division and produces final result (it obviously should include other results of other aggregates in the correct order). Divisor should be checked for 0 in order not to trigger division by zero error.
> Calcite has `AggregateReduceFunctionsRule` that rewrites AVG aggregate (see reduceAvg method) that code can be used a reference.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)