push down filter: extend a projection if some pushed filters are unsupported #14
+129
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Consider the next scenario:
supports_filters_pushdown
returnsExact
on some filter, e.g. "a = 1", where column "a" is not required by the query projection."a" is removed from the table provider projection by "optimize projection" rule.
supports_filters_pushdown
changes a decision and returnsInexact
on this filter the next time. For example, input filters were changed and it prefers to use a new one."a" is not returned to the table provider projection which leads to filter that references a column which is not a part of the schema.
This patch fixes this issue introducing the next logic within a filter push-down rule:
Collect columns that are not used in the current table provider projection, but required for filter expressions. Call it
additional_projection
.If
additional_projection
is empty -- leave all as it was before.Otherwise extend a table provider projection and wrap a plan with an additional projection node to preserve schema used prior to this rule.