Skip to content

Pushdown physical filters to SQLExecutor#160

Merged
hozan23 merged 1 commit into
datafusion-contrib:mainfrom
nuno-faria:pushdown_physical_filters
Feb 26, 2026
Merged

Pushdown physical filters to SQLExecutor#160
hozan23 merged 1 commit into
datafusion-contrib:mainfrom
nuno-faria:pushdown_physical_filters

Conversation

@nuno-faria
Copy link
Copy Markdown
Collaborator

Adds the ability for implementations of SQLExecutor to have access to any filters generated at runtime, like dynamic filters.

This adds a breaking change on the execute method, which receives an extra filters: &[Arc<dyn PhysicalExpr>] argument. However, it can be safely ignored.

self.executor.metrics()
}

fn handle_child_pushdown_result(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some(self.metrics_set.clone_inner())
}

fn gather_filters_for_pushdown(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@backkem backkem requested a review from hozan23 February 16, 2026 08:13
@hozan23 hozan23 merged commit 61e0d82 into datafusion-contrib:main Feb 26, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Feb 26, 2026
@nuno-faria nuno-faria deleted the pushdown_physical_filters branch February 26, 2026 20:13
@ahirner
Copy link
Copy Markdown
Contributor

ahirner commented Apr 17, 2026

Pardon my ignorance @nuno-faria , but what actual SQL backend can benefit from those filters after the sql is dispatched? Or do you parse and unparse the sql again in your use case?

I'm wondering if there is a more efficient API to lazily generate sql once with dynamic filters, at least up until the Pre phase.

@nuno-faria
Copy link
Copy Markdown
Collaborator Author

Pardon my ignorance @nuno-faria , but what actual SQL backend can benefit from those filters after the sql is dispatched? Or do you parse and unparse the sql again in your use case?

I'm wondering if there is a more efficient API to lazily generate sql once with dynamic filters, at least up until the Pre phase.

@ahirner in our case we convert the dynamic filters to SQL and then wrap the original query with them.

@ahirner
Copy link
Copy Markdown
Contributor

ahirner commented Apr 18, 2026

Either your engine gives you IR to layer filters on top or you reformat sql as an inner subquery. I was curious which, because I find the former interesting and the latter inefficient.

@nuno-faria
Copy link
Copy Markdown
Collaborator Author

Either your engine gives you IR to layer filters on top or you reformat sql as an inner subquery. I was curious which, because I find the former interesting and the latter inefficient.

We reformat the SQL as a subquery. I wouldn't call it inefficient since the optimizer in the backend can then pushdown the filters.

@ahirner
Copy link
Copy Markdown
Contributor

ahirner commented Apr 19, 2026

Thank you @nuno-faria . I was referring to the additional unparsing. That's most likely pedantic and not relevant in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants