Skip to content

push down filter: extend a projection if some pushed filters are unsupported #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025

Conversation

askalt
Copy link

@askalt askalt commented Aug 13, 2025

Consider the next scenario:

  1. supports_filters_pushdown returns Exact on some filter, e.g. "a = 1", where column "a" is not required by the query projection.

  2. "a" is removed from the table provider projection by "optimize projection" rule.

  3. supports_filters_pushdown changes a decision and returns Inexact on this filter the next time. For example, input filters were changed and it prefers to use a new one.

  4. "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:

  1. Collect columns that are not used in the current table provider projection, but required for filter expressions. Call it additional_projection.

  2. If additional_projection is empty -- leave all as it was before.

  3. Otherwise extend a table provider projection and wrap a plan with an additional projection node to preserve schema used prior to this rule.

@askalt askalt force-pushed the askalt/fix-projection-after-filter-pushdown branch from 3e58c46 to 0136e6d Compare August 13, 2025 14:48
@askalt askalt self-assigned this Aug 13, 2025
@askalt askalt requested review from psergee and novartole August 13, 2025 14:48
@askalt askalt force-pushed the askalt/fix-projection-after-filter-pushdown branch from 0136e6d to d8867f9 Compare August 14, 2025 10:49
…nsupported

Consider the next scenario:

1. `supports_filters_pushdown` returns `Exact` on some filter, e.g.
   "a = 1", where column "a" is not required by the query projection.

2. "a" is removed from the table provider projection by "optimize projection"
   rule.

3. `supports_filters_pushdown` changes a decision and returns `Inexact` on
   this filter the next time. For example, input filters were changed and
   it prefers to use a new one.

4. "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:

1. Collect columns that are not used in the current table provider projection,
   but required for filter expressions. Call it `additional_projection`.

2. If `additional_projection` is empty -- leave all as it was before.

3. Otherwise extend a table provider projection and wrap a plan with
   an additional projection node to preserve schema used prior to
   this rule.
@askalt askalt force-pushed the askalt/fix-projection-after-filter-pushdown branch from d8867f9 to b7a992b Compare August 14, 2025 12:10
@novartole
Copy link

Thank you for the patch! LGTM.

@askalt askalt removed the request for review from psergee August 15, 2025 08:26
@askalt askalt merged commit 3b3f850 into release-42.0.0 Aug 15, 2025
45 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants