Skip to content

Conversation

@asubiotto
Copy link
Contributor

Filters are safe to be pushed down, so we can override the default behavior here.

Which issue does this PR close?

Filters are safe to be pushed down, so we can override the default behavior
here.

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
@github-actions github-actions bot added core Core DataFusion crate physical-plan Changes to the physical-plan crate labels Oct 14, 2025
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @asubiotto and @adriangb

output:
Ok:
- UnionExec
- DataSourceExec: file_groups={1 group: [[test.parquet]]}, projection=[a, b, c], file_type=test, pushdown_supported=true, predicate=a@0 = foo
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

@adriangb adriangb added this pull request to the merge queue Oct 14, 2025
Merged via the queue into apache:main with commit 0ecd59b Oct 14, 2025
28 checks passed
tobixdev pushed a commit to tobixdev/datafusion that referenced this pull request Nov 2, 2025
Filters are safe to be pushed down, so we can override the default behavior
here.

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
LiaCastaneda pushed a commit to DataDog/datafusion that referenced this pull request Nov 3, 2025
Filters are safe to be pushed down, so we can override the default behavior
here.

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
(cherry picked from commit 0ecd59b)
LiaCastaneda added a commit to DataDog/datafusion that referenced this pull request Nov 4, 2025
* Allow filter pushdown through AggregateExec (apache#18404)

## Which issue does this PR close?

- Closes apache#18399

## Rationale for this change

Right now filters cannot pass through `AggregateExec` nodes, preventing
filter pushdown optimization in queries with GROUP BY/DISTINCT
operations.

## What changes are included in this PR?

- Implemented `gather_filters_for_pushdown()` for `AggregateExec` that
allows filters on grouping columns to pass through to children
- Supports both Pre phase (static filters) and Post phase (dynamic
filters from joins)

Essentially, filter will pass through in the scenarios @asolimando
mentioned
[here](apache#18399 (comment))

## Are these changes tested?

Yes, added three tests:
- `test_aggregate_filter_pushdown`: Positive case with aggregate
functions
- `test_no_pushdown_aggregate_filter_on_non_grouping_column`: Negative
case ensuring filters on aggregate results are not pushed

## Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

(cherry picked from commit 076b091)

* physical-plan: push filters down to UnionExec children (apache#18054)

Filters are safe to be pushed down, so we can override the default behavior
here.

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
(cherry picked from commit 0ecd59b)

* fix: prevent UnionExec panic with empty inputs (apache#17449)

* fix: prevent UnionExec panic with empty inputs

This commit fixes a panic in UnionExec when constructed with empty inputs.
Previously, UnionExec::new(vec![]) would cause an index out of bounds panic
at union.rs:542 when trying to access inputs[0].

Changes:
- Made UnionExec::new() return Result<Self> with proper validation
- Made union_schema() return Result<SchemaRef> with empty input checks
- Added descriptive error messages for empty input cases
- Updated all call sites to handle the new Result return type
- Added comprehensive tests for edge cases

Error messages:
- "UnionExec requires at least one input"
- "Cannot create union schema from empty inputs"

The fix maintains backward compatibility for valid inputs while preventing
crashes and providing clear error messages for invalid usage.

Fixes apache#17052

* refactor: address PR review comments for UnionExec empty inputs fix

- Add new try_new method that returns Result<Arc<dyn ExecutionPlan>>
- Deprecate existing new method in favor of try_new
- Optimize single-input case: try_new returns the input directly
- Remove redundant assert!(result.is_err()) from tests
- Rename test_union_multiple_inputs_still_works to test_union_schema_multiple_inputs
- Update all call sites to use appropriate API (try_new for new code, deprecated new for tests)

This maintains backward compatibility while providing better error handling
and optimization for single-input cases.

* Fix cargo fmt and clippy warnings

- Add proper feature gates for parquet_encryption in datasource-parquet
- Format code to pass cargo fmt checks
- All tests passing

* Fix clippy

---------

Co-authored-by: Eeshan <eeshan@Eeshans-MacBook-Pro.local>
Co-authored-by: ebembi-crdb <ebembi@cockroachlabs.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
(cherry picked from commit b122a16)

---------

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
Co-authored-by: Alfonso Subiotto Marqués <alfonso.subiotto@polarsignals.com>
Co-authored-by: EeshanBembi <33062610+EeshanBembi@users.noreply.github.com>
Co-authored-by: Eeshan <eeshan@Eeshans-MacBook-Pro.local>
Co-authored-by: ebembi-crdb <ebembi@cockroachlabs.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnionExec does not push down filters to children

3 participants