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

RelMdUtil#setAggChildKeys may return an incorrect result

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.38.0
    • 1.39.0
    • core

    Description

      Let us consider an Aggregate such as:

      Aggregate(group=[{9}])
      

      if we call RelMdUtil#setAggChildKeys to obtain the Aggregate's child keys corresponding to the group key 0, it will simply return 0

      for (int bit : groupKey) {
            if (bit < aggRel.getGroupCount()) {
              // group by column
              childKey.set(bit); // <- Potentially wrong!
      

      And this is incorrect, on the child the corresponding key is 9; i.e. we should apply the corresponding conversion:

      for (int bit : groupKey) {
            if (bit < aggRel.getGroupCount()) {
              // group by column
              childKey.set(aggRel.getGroupSet().asList().get(bit)); // <- FIX
      

      as it is done e.g. on column origins for Aggregates:

        public @Nullable Set<RelColumnOrigin> getColumnOrigins(Aggregate rel,
            RelMetadataQuery mq, int iOutputColumn) {
          if (iOutputColumn < rel.getGroupCount()) {
            // get actual index of Group columns.
            return mq.getColumnOrigins(rel.getInput(), rel.getGroupSet().asList().get(iOutputColumn));
          }
      

      Attachments

        Issue Links

          Activity

            People

              rubenql Ruben Q L
              rubenql Ruben Q L
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: