Phoenix500526 opened a new issue, #27157: URL: https://github.com/apache/datafusion/issues/27157
### Describe the bug `APPROX_MEDIAN(x ORDER BY k)` incorrectly treats the sort key k as a percentile argument, causing the query to fail instead of returning the approximate median of x. ### To Reproduce Execute the following SQL in the datafusion-cli (DataFusion CLI v57.0.0-dev) ```SQL > SELECT approx_median(x) FROM (VALUES (1.0, 3), (2.0, 1), (3.0, 2)) t(x, k); +--------------------+ | approx_median(t.x) | +--------------------+ | 2.0 | +--------------------+ 1 row(s) fetched. Elapsed 0.184 seconds. > SELECT approx_median(x ORDER BY k) FROM (VALUES (1.0, 3), (2.0, 1), (3.0, 2)) t(x, k); Execution error: Percentile value for APPROX_MEDIAN must be Float32 or Float64 (got Int64) ``` ### Expected behavior This query fails. The expected result is 2.0, as returned by the same query without `ORDER BY k`. ### Additional context _No response_ ### Willingness to contribute I plan to contribute a fix for this bug independently -- 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]
