You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2022/10/27 23:14:00 UTC

[jira] [Commented] (SPARK-40945) Support built-in function to truncate numbers

    [ https://issues.apache.org/jira/browse/SPARK-40945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17625354#comment-17625354 ] 

Apache Spark commented on SPARK-40945:
--------------------------------------

User 'vinodkc' has created a pull request for this issue:
https://github.com/apache/spark/pull/38419

> 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
>            Priority: Minor
>
> 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-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org