You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Stamatis Zampetakis (Jira)" <ji...@apache.org> on 2022/10/07 15:19:00 UTC
[jira] [Created] (CALCITE-5314) Prune empty parts of a query by exploiting stats/metadata
Stamatis Zampetakis created CALCITE-5314:
--------------------------------------------
Summary: Prune empty parts of a query by exploiting stats/metadata
Key: CALCITE-5314
URL: https://issues.apache.org/jira/browse/CALCITE-5314
Project: Calcite
Issue Type: Improvement
Components: core
Reporter: Stamatis Zampetakis
Currently there is a collection of rules (i.e., [PruneEmptyRules|https://github.com/apache/calcite/blob/4ef9ffe0d4afb80fe95e66d4d9c9e6f5939f70a8/core/src/main/java/org/apache/calcite/rel/rules/PruneEmptyRules.java]) which remove sections of a query plan when it does not produce any rows.
At the moment, the removal requires an empty {{Values}} operator to be in the plan in order to take effect. However, there are cases where queries involve empty relations/tables and in that case we could remove parts of the plan as well.
The information if a relation is empty or not can be derived from metadata. For example, we could check if the [RelMdMaxRowCount|https://github.com/apache/calcite/blob/4ef9ffe0d4afb80fe95e66d4d9c9e6f5939f70a8/core/src/main/java/org/apache/calcite/rel/metadata/RelMdMaxRowCount.java] returns zero to derive that the relation is empty.
Implementation wise there are various alternatives to consider:
* modify the existing PruneEmptyRule to consider metadata;
* add new pruning rules relying exclusively on metadata;
* add new rules checking metadata and turning the empty relation to an empty {{Values}} which can then be handled by existing rules
--
This message was sent by Atlassian Jira
(v8.20.10#820010)