[
https://issues.apache.org/jira/browse/IGNITE-21954?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrey Mashenkov updated IGNITE-21954:
--------------------------------------
Labels: ignite-3 sql tech-debt (was: ignite-3 tech-debt)
> Reuse Calcite map-reduce aggregates code.
> -----------------------------------------
>
> Key: IGNITE-21954
> URL: https://issues.apache.org/jira/browse/IGNITE-21954
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Reporter: Andrey Mashenkov
> Priority: Major
> Labels: ignite-3, sql, tech-debt
>
> *Motivation*
> As for now we have custom code that splits aggregate function into map-reduce
> stages. See class/method usage for details:
>
> {code:java}
> MapReduceAggregates.buildAggregates{code}
>
> Some functions (e.g. AVG) are split into 2 functions which may have
> incompatible types (e.g. COUNT returns BIGINT on map-phase, but SUM on
> reduce-phase requires DECIMAL).
> This forces adding a Projection in between, but this additional stage looks
> synthetic and rises costs.
> I've found Calcite already have `AggregateReduceFunctionsRule`, which splits
> functions in different way (using `CASE-WHEN` clause instead of Project), and
> can be reused.
> *Suggestion*
> Let's try to reuse Calcite rule and/or splitting functions, and drop
> duplicating code from our codebase.
> Otherwise, if there are obstacles, go the similar way at least.
> Fix planner tests, which expects a Project between map and reduce phases.
> *Expectation*
> After this fix, we should observe no projection in between map and reduce
> aggregate phases.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)