Yuvraj-cyborg opened a new pull request, #19582:
URL: https://github.com/apache/datafusion/pull/19582

   Closes #19536 - Median() truncates integers
   
   ## Rationale for this change:
   
   The current implementation of median() returns the same type as the input. 
For integer inputs with an even count, this causes truncation when averaging 
the two middle values (e.g., median(1, 2, 3, 4) returns 2 instead of 2.5).
   
   ## Changes in PR:
   
   - Modified return_type to return Float64 for integer inputs (matching 
percentile_cont behavior)
   - Updated state_fields to store intermediate state as Float64 for integer 
inputs
   - Updated accumulator to use Float64Type accumulator for integer inputs
   - Updated create_groups_accumulator to use Float64Type groups accumulator 
for integer inputs
   - Updated MedianAccumulator::update_batch to cast integers to Float64
   - Updated MedianGroupsAccumulator::update_batch to cast integers to Float64
   - Updated DistinctMedianAccumulator::update_batch to cast integers to Float64
   - Updated sqllogictest files to expect Float64 return types for integer 
inputs
   
   ## Test Coverage:
   
   Yes - Updated existing sqllogictests in aggregate.slt and 
aggregate_skip_partial.slt to expect Float64 return types.
   
   ## Are there any user-facing changes?
   
   Yes - Breaking change: median() now returns Float64 instead of the input 
integer type for integer inputs. Users who relied on integer return types will 
need to cast explicitly if needed.


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