Vinod KC created SPARK-40945: -------------------------------- Summary: Support built-in function to truncate numbers Key: SPARK-40945 URL: https://issues.apache.org/jira/browse/SPARK-40945 Project: Spark Issue Type: Improvement Components: SQL Affects Versions: 3.4.0 Reporter: Vinod KC
Built-in function TRUNC shall truncate numbers to the previous integer or decimal. It shall optionally accept a second integer argument to indicate the number of decimal places for rounding, in either direction. When the second argument is absent, the function rounds to the nearest whole number. When the second argument is specified, the function rounds to the nearest number with n decimal places of precision. trunc ( numeric ) -> numeric trunc ( double precision ) -> double precision eg: trunc(123.4382) -> 123 trunc(-123.4382) -> -123 trunc ( v numeric, s integer ) -> numeric Truncates v to s decimal places eg: trunc(123.4382, 2) -> 123.43 trunc(123.4382, 0) -> 123 trunc(123.4382, -1) -> 120 trunc(123.4382, -2) -> 100 trunc(123.4382, -3) -> 0 Reference : PostgreSQL: https://www.postgresql.org/docs/15/functions-math.html AWS Redshift: https://docs.aws.amazon.com/redshift/latest/dg/r_TRUNC.html Presto : https://prestodb.io/docs/current/functions/math.html?highlight=trunc#id3 -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org