rubenada commented on a change in pull request #1918:
URL: https://github.com/apache/calcite/pull/1918#discussion_r417877427



##########
File path: core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java
##########
@@ -277,7 +278,11 @@ private static boolean isEmpty(RelNode node) {
           if (sort.fetch != null
               && !(sort.fetch instanceof RexDynamicParam)
               && RexLiteral.intValue(sort.fetch) == 0) {
-            call.transformTo(call.builder().push(sort).empty().build());
+            RelNode emptyValues = call.builder().push(sort).empty().build();
+            emptyValues = emptyValues.copy(
+                emptyValues.getTraitSet().replace(sort.getCollation()),
+                Collections.emptyList());

Review comment:
       The (non propagation of) Collation trait is the root cause of this 
issue. So propagating just the Collation seems the easiest way to fix this bug 
(but arguably maybe not the "most correct" one).
   Previously, I tried to propagate other traits as well, but it did not work 
as expected:
   _Propagating all traits does not seem a good solution. [...] there are some 
tests failing because of the following scenario: we have an enumerable single 
rel + logical empty values, so we replace the whole thing with an empty values 
(which in our case is a LogicalValues, as returned by RelBuilder#empty). If we 
try to propagate all traits it will fail, because we would be trying to 
propagate the EnumerableConvention towards a LogicalValues. So what should be 
our strategy here? Should we propagate all traits except the convention? Am I 
missing something in the trait propagation process?_




----------------------------------------------------------------
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:
[email protected]


Reply via email to