adriangb opened a new pull request, #27937:
URL: https://github.com/apache/datafusion/pull/27937

   ## Which issue does this PR close?
   
   No issue. alamb suggested it in a review of 
https://github.com/apache/datafusion/pull/27925 
([comment](https://github.com/apache/datafusion/pull/27925#discussion_r4762251668)).
   
   ## Rationale for this change
   
   `PartialSortExec` sorts each run of rows with equal values of its common 
prefix. It returns wrong rows if its input is not sorted by that prefix. It 
does not declare this in `required_input_ordering`, so optimizer rules and 
`SanityCheckPlan` cannot see the requirement. A rule that changes the input 
ordering then gives wrong results that nothing detects.
   
   https://github.com/apache/datafusion/pull/27925 needs the declaration. It 
decides which orderings it must keep from `required_input_ordering` and 
`maintains_input_order`.
   
   ## What changes are included in this PR?
   
   `PartialSortExec::required_input_ordering` returns the first 
`common_prefix_length` sort expressions.
   
   ## What is the testing strategy for this PR?
   
   A unit test checks the declared requirement. The existing `PartialSortExec` 
plans in the sqllogictests and in the `enforce_sorting` tests are unchanged, 
because `EnsureRequirements` creates the operator only when the input already 
satisfies the prefix.
   
   ### AI assistance
   
   Claude Code wrote the code, the test and this description at the request of 
the PR author.
   
   ## Are there any user-facing changes?
   
   No public API changes.
   
   🤖 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]

Reply via email to