lyne7-sc opened a new pull request, #22591:
URL: https://github.com/apache/datafusion/pull/22591

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes #.
   
   ## Rationale for this change
   
   When evaluating `Date32 - Date32` or `Date64 - Date64`, DataFusion needs to 
return an Int64 representing the difference in days(after #19563). The current 
implementation went through Arrow's sub_wrapping, then converted to Int64 days. 
This allocates an unnecessary intermediate array and bypasses vectorized 
kernels.
   
   Since Date32/Date64 are just i32/i64 under the hood, we can compute the day 
difference directly on the native values.
   
   <!--
    Why are you proposing this change? If this is already explained clearly in 
the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your 
changes and offer better suggestions for fixes.  
   -->
   
   ## What changes are included in this PR?
   
   - Replace `apply_date_subtraction + duration_to_days` with 
`subtract_date_to_days`, which operates directly on primitive values using 
`binary()/unary()`
   - Add date subtraction benchmarks
   
   <!--
   There is no need to duplicate the description in the issue here but it is 
sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   ### Benchmarks
   ```
   group                               baseline                               
optimized
   -----                               --------                               
---------
   date32_subtract/20_percent_nulls    21.16    30.9±4.15µs        ? ?/sec    
1.00  1462.0±129.72ns        ? ?/sec
   date32_subtract/no_nulls            18.32    21.9±2.72µs        ? ?/sec    
1.00  1196.5±123.89ns        ? ?/sec
   date64_subtract/20_percent_nulls    9.97     34.3±2.26µs        ? ?/sec    
1.00      3.4±0.12µs        ? ?/sec
   date64_subtract/no_nulls            7.65     25.3±2.77µs        ? ?/sec    
1.00      3.3±0.09µs        ? ?/sec
   ```
   
   ## Are these changes tested?
   
   Yes, new UTs and exist slt
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are 
they covered by existing tests)?
   -->
   
   ## Are there any user-facing changes?
   
   No.
   
   <!--
   If there are user-facing changes then we may require documentation to be 
updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api 
change` label.
   -->
   


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