haohuaijin opened a new issue, #25220:
URL: https://github.com/apache/datafusion/issues/25220

   ### Is your feature request related to a problem or challenge?
   
   
   DataFusion can retain an unnecessary sort for integer arithmetic even when 
exact column extrema prove overflow is impossible.
   
   For a Parquet input known to be ordered by `a ASC`, with exact bounds `a ∈ 
[1, 3]`:
   
   ```sql
   SELECT a + 1 AS x FROM t ORDER BY x;
   ```
   
   The output is already ordered, but range-free inference retains `SortExec`.
   
   ### Describe the solution you'd like
   
   Use existing execution-plan statistics to supply exact integer bounds during 
projection ordering inference. Remove the sort when addition or subtraction is 
proven safe. Retain it when ordering cannot be proven.
   
   Statistics establish value bounds; the input must independently have a known 
ordering.
   
   ### Describe alternatives you've considered
   
   Keep the existing sort, or introduce a separate bounds-propagation 
interface. Reusing existing statistics avoids another execution-plan interface.
   
   ### Additional context
   
   _No response_


-- 
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