Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-21954

Reuse Calcite map-reduce aggregates code.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • sql
    • Docs Required, Release Notes Required

    Description

      Motivation

      As for now we have custom code that splits aggregate function into map-reduce stages. See class/method usage for details:

       

      MapReduceAggregates.buildAggregates

       

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              amashenkov Andrey Mashenkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: