zhuqi-lucas opened a new issue, #28011: URL: https://github.com/apache/datafusion/issues/28011
## Is your feature request related to a problem or challenge? Follow-up to #27982, part of #24270. When `UnionExec::try_pushdown_sort` gets mixed answers from its inputs, for example one input `Exact` through an exact reverse scan and another `Unsupported`, the sort stays above the union. #27982 then keeps each `Exact` input as it was: the exact rewrite buffers a decoded row group to read it back to front, which only pays off when it replaces the sort (see the memory limit repro in https://github.com/apache/datafusion/pull/27982#discussion_r4784847211). That input could still help the kept TopK with the cheap `Inexact` rewrite: row groups in reverse order, no row buffering, so the largest values come first and the TopK dynamic filter tightens early. The union cannot get it. `try_pushdown_sort` returns a single answer, and once an input answers `Exact`, its parent has no way to ask for the `Inexact` form instead. `FileScanConfig::try_pushdown_sort` already does this internally: when its exact answer cannot keep the ordering, it falls back to the inexact pushdown of the original source. A node above it cannot. ## Describe the solution you'd like Let a parent ask for a rewrite that is only allowed to be `Inexact`, for example through an option on `try_pushdown_sort`. When the sort stays, `UnionExec` asks its `Exact` inputs again in that mode and keeps the `Inexact` rewrite. Other nodes that combine their inputs' answers and keep the sort can do the same. ## Describe alternatives you've considered - Keep the `Exact` rewrite under the kept sort: extra memory per partition, the regression found in #27982. - Keep the input unchanged, as #27982 does: correct, but the TopK reads that input in storage order. ## Additional context Part of #24270. -- 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]
