vinodkc commented on PR #38419: URL: https://github.com/apache/spark/pull/38419#issuecomment-1309200366
@cloud-fan , Though ceil/floor takes a second parameter for num of digits to retain, the behaviour is different in trunc and ceil/floor functions Eg: FLOOR vs TRUNC comparison | FLOOR | Result | TRUNC | Result | | |---|---|---|---|---| | SELECT FLOOR(-2.5, 0) | -3 |SELECT TRUNC(-2.5, 0) | -2 | | | SELECT FLOOR(-3.5, 0) | -0.4 | SELECT TRUNC(-3.5, 0) | -3 | | | SELECT FLOOR(-35, -1) | -40 | SELECT TRUNC(-35, -1) | -30 | | | SELECT FLOOR(-9.9, 0) | -10 | SELECT TRUNC(-9.9, 0) |-9 | | | SELECT FLOOR(CAST(-99 AS DECIMAL(2, 0)), -1) | -100 | SELECT TRUNC(CAST(-99 AS DECIMAL(2, 0)), -1) | -90 | | Eg: CEIL vs TRUNC comparison | CEIL | Result | TRUNC | Result | | |---|---|---|---|---| |SELECT CEIL(2.5, 0) | 3 | SELECT TRUNC(2.5, 0) | 2 | | |SELECT CEIL(3.5, 0) | 4 | SELECT TRUNC(3.5, 0) | 3 | | |SELECT CEIL(0.35, 1) |0.4 | SELECT TRUNC(0.35, 1) | 0.3 | | |SELECT CEIL(35, -1) | 40 | SELECT TRUNC(35, -1 | 30 | | |SELECT CEIL(5, 0) | 5 | SELECT TRUNC(5, 0)| 5 | | |SELECT CEIL(9.9, 0) | 10 | SELECT TRUNC(9.9, 0) | 9 | | |SELECT CEIL(CAST(99 AS DECIMAL(2, 0)), -1) | 100 | SELECT TRUNC(CAST(99 AS DECIMAL(2, 0)), -1) | 90 | | -- 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]
