Stamatis Zampetakis created CALCITE-5705: --------------------------------------------
Summary: Generalize RemoveEmptySingleRule to work with arbitrary relations and pruning configurations Key: CALCITE-5705 URL: https://issues.apache.org/jira/browse/CALCITE-5705 Project: Calcite Issue Type: Improvement Components: core Reporter: Stamatis Zampetakis Assignee: Stamatis Zampetakis Fix For: 1.35.0 Currently [RemoveEmptySingleRule|https://github.com/apache/calcite/blob/b0b27e8872b33c5ab203e0e2365d267a594c80be/core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java#LL285C23-L285C44] can only transform {{SingleRel}} relations to empty. However, the logic inside the {{matches}} method is at the most part capable of handling any kind of relation including those that have multiple children. By generalizing the {{RemoveEmptySingleRule}} to work with arbitrary relations we can refactor other pruning rules such as those created by [CorrelateLeftEmptyRuleConfig|https://github.com/apache/calcite/blob/b0b27e8872b33c5ab203e0e2365d267a594c80be/core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java#L588] without the need for creating more classes and duplicating code. Moreover by changing the constructor to accept {{PruneEmptyRule.Config}} instead of {{RemoveEmptySingleRuleConfig}} we can reduce code duplication further since configurations such as {{ZeroMaxRowsRuleConfig}} and {{SortFetchZeroRuleConfig}} could be modified to create instances of {{RemoveEmptySingleRule}}. This is mainly a refactoring to simplify pruning rules and remove duplicate logic. The change is fully backwards compatible. -- This message was sent by Atlassian Jira (v8.20.10#820010)