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

AggregateUnionTransposeRule may assign wrong aggregate function to input

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.26.0
    • None
    • core
    • None

    Description

      Consider the following query tree:

      1: Aggregate[SUM($0):BIGINT]
      2:   Union[$0:BIGINT]
      3:     Input[$0:BIGINT]
      4:     Input[$0:BIGINT NOT NULL]
      

      The Union's row type is BIGINT, and Aggergate's row type is BIGINT as well.

      When the AggregateUnionTransposeRule rule pushes Aggregate below Union, it installs the aggregate call from the original Aggregate to new aggregates:

      1: Aggregate[SUM($0):BIGINT]
      2:   Union[$0:BIGINT]
      3:     Aggregate[SUM($0):BIGINT]
      4:       Input[$0:BIGINT]
      5:     Aggregate[SUM($0):BIGINT]
      6:       Input[$0:BIGINT NOT NULL]
      

      This leads to a Litmus failure in the Aggregate on line 5 because the aggregate call returns BIGINT, while it should return BIGINT NOT NULL.

      The solution is to re-create aggregate calls for inputs and let Calcite deduce the return type.

      Attachments

        Activity

          People

            Unassigned Unassigned
            vozerov Vladimir Ozerov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: