vinodkc commented on PR #38419:
URL: https://github.com/apache/spark/pull/38419#issuecomment-1307418547
@cloud-fan , thanks for the review/question.
`floor` returns a numeric value containing the largest integers not greater
than the corresponding elements of x.
`trunc` returns a numeric value containing the integers formed by
truncating the values in x toward 0
Eg:
`trunc(x, n)` → double
Returns x truncated to n decimal places. n can be negative to truncate n
digits left of the decimal point. Unlike ceil or floor, this function will not
round up/down the number, rather it just truncates by replacing with '0'
Example:
`trunc(REAL '12.333', -1)` -> result is `10`
`trunc(REAL '123.333', -2)` -> result is `100`
`trunc(REAL '12.333', 0)` -> result is `12`
`trunc(REAL '12.333', 1)` -> result is `12.3`
Reference from other Database :
- [AWS redshift](https://docs.aws.amazon.com/redshift/latest/dg/r_TRUNC.html)
- [PostgreSQL](https://www.postgresql.org/docs/15/functions-math.html)
-
[Presto](https://prestodb.io/docs/current/functions/math.html?highlight=trunc#id3)
-
[Mysql](https://database.guide/mysql-truncate-function-truncate-a-number-to-a-specified-number-of-decimal-places/)
-
[Oracle](https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions200.htm#:~:text=The%20TRUNC%20(number)%20function%20returns,left%20of%20the%20decimal%20point.)
`floor(x)`
Returns x rounded down to the nearest integer.
--
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]