You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/07/09 16:38:37 UTC

[GitHub] [calcite] jinxing64 commented on a change in pull request #1310: [CALCITE-3113] Equivalent MutableAggregates with different row types should match with each other.

jinxing64 commented on a change in pull request #1310: [CALCITE-3113] Equivalent MutableAggregates with different row types should match with each other.
URL: https://github.com/apache/calcite/pull/1310#discussion_r301684715
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
 ##########
 @@ -531,8 +531,22 @@ assert equalType(
               final UnifyResult result = rule.apply(call);
               if (result != null) {
                 ++count;
-                attempted.add(new Replacement(result.call.query, result.result));
-                MutableRel parent = result.call.query.replaceInParent(result.result);
+                final MutableRel result1;
+                if (targetDescendant == target
+                    && !result.result.rowType.equals(result.call.query.rowType)) {
+                  // When target and query match with each other but have different
+                  // rowTypes, we add a MutableProject for compensation, thus to
+                  // assure the rowType of the replaced is exactly as before.
+                  final RexBuilder rexBuilder = target.cluster.getRexBuilder();
+                  List<RexNode> projects = new ArrayList<>(
+                      rexBuilder.identityProjects(result.call.query.rowType));
+                  result1 = MutableProject.of(
+                      result.call.query.rowType, result.result, projects);
+                } else {
+                  result1 = result.result;
+                }
+                attempted.add(new Replacement(result.call.query, result1));
+                MutableRel parent = result.call.query.replaceInParent(result1);
 
 Review comment:
   Sure

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services