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


##########
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:
   What matters is that the operator has a single OUTPUT, and they all do.
   Maybe you can find a way to do it, even if it means writing a bit more code 
to handle operators with more than 1 input.



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