cool9850311 opened a new pull request, #27669: URL: https://github.com/apache/datafusion/pull/27669
## Which issue does this PR close? - Closes #27494. - Part of #27495. ## Rationale for this change `OFFSET n LIMIT m` against a source that pushes the skip down makes `file_row_index()` and `input_file_name()` fail: ```sql SELECT file_row_index() FROM small OFFSET 1 LIMIT 2; -- Execution error: file_row_index() is source dependent and cannot be evaluated directly ``` Either clause on its own is fine. The pushed-down skip wraps the scan in a `GlobalLimitExec`, and with more than one file group a `CoalescePartitionsExec` under that. Those nodes land between the scan and the projection holding the marker, and no projection swaps past a `GlobalLimitExec`, so the marker never reaches the source that can resolve it. ## What changes are included in this PR? #27152 added a split that moves leaf expressions past a round-robin `RepartitionExec`, testing for that one node inline. The nodes a leaf projection may descend are now listed in one place, `split_host_child`, with `GlobalLimitExec` and `CoalescePartitionsExec` added, and `split_host_chain` walks a stack of them so a leaf descends past all of them in one pass. The arms are an allowlist: a node must neither reference its input's columns nor change them on the way out, and meeting that is necessary rather than sufficient, so `LocalLimitExec` is deliberately left off. Only leaf expressions descend. Ones that must stay in place are left above the limit, so they are not evaluated on the rows the skip discards. `get_field` reaches the scan under an `OFFSET` for the same reason, which is what #27495 asks for. That issue's `EXPLAIN` coverage is a follow-on PR, so it stays open here. ## What is the testing strategy for this PR? Yes: value and `EXPLAIN` queries in `datafusion/sqllogictest/test_files/file_row_index.slt` (bare and wrapped markers, a computed sibling in the same projection, a repartition above the limit, `input_file_name()`, two file groups, a JSON listing table, and `OFFSET 0 LIMIT n` plus `OFFSET n` with no fetch as controls), and eleven unit tests in `datafusion/core/tests/physical_optimizer/projection_pushdown.rs` showing each input and output plan. Reverting the rule and keeping the tests turns 8 of those 11 unit tests and 11 rows of `file_row_index.slt` red. ## Are there any user-facing changes? `file_row_index()` and `input_file_name()` under `OFFSET n LIMIT m` return rows instead of an error. No API change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
