Stamatis Zampetakis created CALCITE-4513: --------------------------------------------
Summary: RelBuilder.aggregate destroys input traits when pruning unused fields of project Key: CALCITE-4513 URL: https://issues.apache.org/jira/browse/CALCITE-4513 Project: Calcite Issue Type: Bug Components: core Affects Versions: 1.23.0 Reporter: Stamatis Zampetakis Assignee: Stamatis Zampetakis RelBuilder attempts to prune unused fields when the underlying input is a project and the respective configuration ({{RelBuilder.Config#pruneInputOfAggregate}}) is enabled (CALCITE-3763). As a result of this optimization a new project operator is introduced in the plan. The new operator is created via {{Project#copy}} method but instead of retaining or adapting the previous traitset a new one is created (https://github.com/apache/calcite/blob/94502f51e6a12cd53cec88b39d21b4fec6070428/core/src/main/java/org/apache/calcite/tools/RelBuilder.java#L1922). {code:java} r = project.copy(cluster.traitSet(), project.getInput(), newProjects, builder.build()); {code} The main problem with that is that a {{HiveProject}} operator which used to be in {{HiveConvention}} will be transformed to a {{HiveProject}} operator in {{Convention.None}}. Obviously other traits (apart from {{Convention}}) potentially present in the operator are also lost after the transformation. -- This message was sent by Atlassian Jira (v8.3.4#803005)