Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4818

AggregateExpandDistinctAggregatesRule must infer correct data type for top aggregate calls

    XMLWordPrintableJSON

Details

    Description

      When SUM data type derivation is more complex, e.g.:

      SUM(TINYINT | SMALLINT | INTEGER) -> BIGINT
      SUM(BIGINT) -> DECIMAL
      

      The rule AggregateExpandDistinctAggregatesRule creates the top aggregate calls with invalid type for not distinct calls.

      e.g. SELECT SUM(comm), SUM(DISTINCT comm) FROM emp

      Please take a look at the reproducer in the PR.

      Proposed fix: infer type of top aggregates by input row type. Pass null type to the call method AggregateCall#create.

      Attachments

        Issue Links

          Activity

            People

              tledkov-gridgain Taras Ledkov
              tledkov-gridgain Taras Ledkov
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h