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

RelBuilder drops traits when aggregating over duplicate projected fields

    XMLWordPrintableJSON

Details

    Description

      In the RelBuilder method aggregate_, when (config.pruneInputOfAggregate() && r instanceof Project) line 2443 the Project will be rewritten to remove unused columns.

      When this happens, the new Project will be created with the following line

      {{{}2487: r =
      {}}}2488:   project.copy(cluster.traitSet(), project.getInput(), newProjects,
      2489:     builder.build());
       
      The use of cluster.traitSet() returns emptyTraitSet which is always going to use Convention.NONE regardless of the Rebuilder's ProjectFactory.

      In the case of a query plan using a non-Logical convention FOO, with FooProject nodes that require the FOO convention, RelBuilder will normally happily produce FooProject nodes with FOO convention, allowing many CoreRules to be easily reused for custom Conventions.

      However, while RelBuilder will produce FooProject with FOO convention in the majority of cases, for the one specific case of column pruning a Project input to an aggregate, it will instead product a FooProject with NONE convention.

      Attachments

        Issue Links

          Activity

            People

              jduong James Duong
              adamkennedy77 Adam Kennedy
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: