xndai commented on a change in pull request #1918: [CALCITE-3926] 
CannotPlanException when an empty LogicalValues requires a certain collation
URL: https://github.com/apache/calcite/pull/1918#discussion_r409070045
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java
 ##########
 @@ -400,7 +401,13 @@ private static boolean isEmpty(RelNode node) {
 
     public void onMatch(RelOptRuleCall call) {
       SingleRel single = call.rel(0);
-      call.transformTo(call.builder().push(single).empty().build());
+      RelNode emptyValues = call.builder().push(single).empty().build();
+      if (single instanceof Sort) {
+        emptyValues = emptyValues.copy(
+            emptyValues.getTraitSet().replace(((Sort) single).getCollation()),
+            Collections.emptyList());
+      }
 
 Review comment:
   Agree with @hsyuan . This trait replacement is a one-off thing just for 
PruneEmptyRule. I am not convinced it should be available in RelBuilder. 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to