tarekakrout2021 commented on issue #22269: URL: https://github.com/apache/datafusion/issues/22269#issuecomment-4478613435
Changing the rounding to use the round_even breaks other tests, namely: [test_round_f32](https://github.com/apache/datafusion/blob/main/datafusion/functions/src/math/round.rs#L759) and [test_round_f64](https://github.com/apache/datafusion/blob/main/datafusion/functions/src/math/round.rs#L778). For : `select round(125.2345,3);` round_even would output 125.234, however postgresql outputs 125.235. The reason is that postgres does not allow rounding with precision on floats : ``` postgres=# SELECT round(2.5::float8, 3); ERROR: function round(double precision, integer) does not exist LINE 1: SELECT round(2.5::float8, 3); ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. ``` This query: `select round(125.2345,3); ` will use the numeric type and not the float type. ``` postgres=# SELECT pg_typeof(round(125.2345, 3)); pg_typeof ----------- numeric (1 row) ``` DuckDB also confirms this: memory=# SELECT round(125.2345, 3); ┌────────────────────┐ │ round(125.2345, 3) │ │ numeric(7,3) │ ├────────────────────┤ │ 125.235 │ └────────────────────┘ memory=# SELECT round_even(125.2345, 3); ┌─────────────────────────┐ │ round_even(125.2345, 3) │ │ double │ ├─────────────────────────┤ │ 125.234 │ └─────────────────────────┘ Could you please clarify if the tests should be changed, such that we always use round_even, or should a round_even function be exposed like duckdb ? @kumarUjjawal -- 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]
