Skip to content

Conversation

@jackkleeman
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

Parent dynamic filters should be remapped from input to output schema, otherwise the indices can be wrong

What changes are included in this PR?

  • Use with_child to remap parent filters
  • Add unit test that catches this issue

Are these changes tested?

Yes

Are there any user-facing changes?

No

@jackkleeman jackkleeman marked this pull request as ready for review February 11, 2026 09:22
@github-actions github-actions bot added the physical-plan Changes to the physical-plan crate label Feb 11, 2026
@notashes
Copy link
Contributor

notashes commented Feb 11, 2026

nice fix! I was working on the same #20283! I'll close mine as this already contains tests!

Copy link
Contributor

@adriangb adriangb left a comment

Choose a reason for hiding this comment

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

Great fix!

@adriangb
Copy link
Contributor

Merging to get the fix in soon. @jackkleeman I wonder if we can reproduce this from an SLT test? Do you have a shape of query that you first noticed this with?

@adriangb adriangb added this pull request to the merge queue Feb 11, 2026
Merged via the queue into apache:main with commit 0f74dbf Feb 11, 2026
32 checks passed
@jackkleeman
Copy link
Contributor Author

jackkleeman commented Feb 11, 2026

I wonder if we can reproduce this from an SLT test? Do you have a shape of query that you first noticed this with?

I struggled because the datasources seem to do a column name remapping and are tolerant of this type of mismatch? it makes me wonder if i should be doing column name remapping too in my tableprovider

this shape should cover it select 1 from sys_invocation_status where partition_key is not null order by modified_at limit 5. ie, any filter on a column that isnt modified_at, and then a topk on modified_at. It needs dynamic filter pushdown, and the error won't occur until the dynamic filter is updated with a modified_at bound (the bound will be interpreted as partition_key > ).

@jackkleeman jackkleeman deleted the filter-remap-parent branch February 11, 2026 12:29
@adriangb
Copy link
Contributor

I struggled because the datasources seem to do a column name remapping and are tolerant of this type of mismatch? it makes me wonder if i should be doing column name remapping too in my tableprovider

I guess they are doing it to handle some cases and that makes them more resilient. In theory I'm not sure, maybe it's not needed. In practice it's probably a good safety net for you to do that as well.

@jackkleeman
Copy link
Contributor Author

there might be an argument to disable that behaviour for the tests so that we catch these types of issues

@adriangb
Copy link
Contributor

there might be an argument to disable that behaviour for the tests so that we catch these types of issues

IIRC it exists to adapt logical to physical schemas, which is a real thing / not paving over bugs. I'd guess it happens in https://github.com/apache/datafusion/blob/main/datafusion/physical-expr-adapter/src/schema_rewriter.rs.

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

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] [v52 regression] FilterExec parent dynamic filters have incorrect column indices

3 participants