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

   Great catch. I looked into it, and it seems like it's wrapping around due to 
integer overflow while taking the average of the middle two values (since the 
count is even).
   
   ```
   low: [-85], high: -56, median: 57 datatype: Int8
   ```
   
   -85 + -56 = -141 -> wraparound to 115
   Then 115 / 2 -> 57.5 -> 57 (truncated due to integer type)
   
   What's our desired behavior in this case? We could promote to a larger 
datatype to perform the calculation. Also is it intentional to return the value 
as a truncated integer instead of a float?
   
   _Originally posted by @petern48 in 
https://github.com/apache/datafusion/pull/19278#discussion_r2617308599_
   
   The overflow part was fixed in 
https://github.com/apache/datafusion/issues/19322, but the truncation issue 
remains. Other databases seem to return a float: 
https://github.com/apache/datafusion/issues/19322#issuecomment-3693042381


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