alex-plekhanov commented on a change in pull request #9647:
URL: https://github.com/apache/ignite/pull/9647#discussion_r773174243
##########
File path:
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/rule/logical/ProjectScanMergeRule.java
##########
@@ -92,54 +80,70 @@ private ProjectScanMergeRule(Config config) {
RelOptCluster cluster = scan.getCluster();
List<RexNode> projects = relProject.getProjects();
RexNode cond = scan.condition();
+ ImmutableBitSet requiredColumns = scan.requiredColumns();
+ List<RexNode> scanProjects = scan.projects();
- // projection changes input collation and distribution.
- RelTraitSet traits = scan.getTraitSet();
-
- traits = traits.replace(TraitUtils.projectCollation(
- TraitUtils.collation(traits), projects, scan.getRowType()));
-
- traits = traits.replace(TraitUtils.projectDistribution(
- TraitUtils.distribution(traits), projects, scan.getRowType()));
+ // Set default traits, real traits will be calculated for physical
node.
+ RelTraitSet traits = cluster.traitSet();
IgniteTable tbl = scan.getTable().unwrap(IgniteTable.class);
IgniteTypeFactory typeFactory = Commons.typeFactory(cluster);
- ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
-
- new RexShuttle() {
- @Override public RexNode visitInputRef(RexInputRef ref) {
- builder.set(ref.getIndex());
- return ref;
- }
- }.apply(projects);
- new RexShuttle() {
- @Override public RexNode visitLocalRef(RexLocalRef inputRef) {
- builder.set(inputRef.getIndex());
- return inputRef;
- }
- }.apply(cond);
-
- ImmutableBitSet requiredColumns = builder.build();
-
- Mappings.TargetMapping targetMapping = Commons.mapping(requiredColumns,
- tbl.getRowType(typeFactory).getFieldCount());
-
- projects = new RexShuttle() {
- @Override public RexNode visitInputRef(RexInputRef ref) {
- return new
RexLocalRef(targetMapping.getTarget(ref.getIndex()), ref.getType());
+ if (requiredColumns == null) {
+ assert scanProjects == null;
+
+ ImmutableBitSet.Builder builder = ImmutableBitSet.builder();
+
+ new RexShuttle() {
+ @Override public RexNode visitInputRef(RexInputRef ref) {
+ builder.set(ref.getIndex());
+ return ref;
+ }
+ }.apply(projects);
+
+ new RexShuttle() {
+ @Override public RexNode visitLocalRef(RexLocalRef inputRef) {
+ builder.set(inputRef.getIndex());
+ return inputRef;
+ }
+ }.apply(cond);
+
+ requiredColumns = builder.build();
+
+ Mappings.TargetMapping targetMapping =
Commons.mapping(requiredColumns,
+ tbl.getRowType(typeFactory).getFieldCount());
+
+ projects = new RexShuttle() {
+ @Override public RexNode visitInputRef(RexInputRef ref) {
+ return new
RexLocalRef(targetMapping.getTarget(ref.getIndex()), ref.getType());
+ }
+ }.apply(projects);
+
+ cond = new RexShuttle() {
+ @Override public RexNode visitLocalRef(RexLocalRef ref) {
+ return new
RexLocalRef(targetMapping.getTarget(ref.getIndex()), ref.getType());
+ }
+ }.apply(cond);
+ }
+ else
+ projects = RexUtils.replaceInputRefs(projects);
+
+ if (scanProjects != null) {
+ if (projects != null) {
Review comment:
FIxed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]