mihaibudiu commented on code in PR #5132:
URL: https://github.com/apache/calcite/pull/5132#discussion_r3684007244


##########
core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java:
##########
@@ -525,20 +541,20 @@ public interface IntersectEmptyPruneRuleConfig extends 
PruneEmptyRule.Config {
     }
   }
 
-  /** Configuration for a rule that prunes a Sort if it has limit 0. */
+  /** Configuration for a rule that prunes a Sort if it is definitely empty,
+   * for example because its input is empty, it has {@code LIMIT 0}, or its
+   * {@code OFFSET} skips more rows than the input can produce. */
   @Value.Immutable
-  public interface SortFetchZeroRuleConfig extends PruneEmptyRule.Config {
-    SortFetchZeroRuleConfig DEFAULT = ImmutableSortFetchZeroRuleConfig.of()
+  public interface SortEmptyRuleConfig extends PruneEmptyRule.Config {
+    SortEmptyRuleConfig DEFAULT = ImmutableSortEmptyRuleConfig.of()
         .withOperandSupplier(b -> b.operand(Sort.class).anyInputs())
-        .withDescription("PruneSortLimit0");
+        .withDescription("PruneSortIfEmpty");
 
     @Override default PruneEmptyRule toRule() {
       return new RemoveEmptySingleRule(this) {
         @Override public boolean matches(final RelOptRuleCall call) {
-          Sort sort = call.rel(0);
-          return sort.fetch != null
-              && !(sort.fetch instanceof RexDynamicParam)
-              && 
RexLiteral.bigDecimalValue(sort.fetch).equals(BigDecimal.ZERO);
+          final Sort sort = call.rel(0);

Review Comment:
   I think this is an improvement, but I still don't understand why this cannot 
be applied to any Rel node.



-- 
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]

Reply via email to