GitHub user wangyum opened a pull request:

    https://github.com/apache/spark/pull/22419

    [SPARK-23906][SQL] Add UDF TRUNCATE(number)

    ## What changes were proposed in this pull request?
    
    Add UDF `TRUNCATE(number)`:
    ```sql
    > SELECT TRUNCATE(1234567891.1234567891, 4);
     1234567891.1234
    > SELECT TRUNCATE(1234567891.1234567891, -4);
     1234560000
    > SELECT TRUNCATE(1234567891.1234567891, 0);
     1234567891
    > SELECT TRUNCATE(1234567891.1234567891);
     1234567891
    ```
    
    It's similar to MySQL [TRUNCATE(X, 
D)](https://dev.mysql.com/doc/refman/8.0/en/mathematical-functions.html#function_truncate)
    
    ## How was this patch tested?
    
    unit tests


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/wangyum/spark SPARK-23906

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/22419.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #22419
    
----
commit b5365e28bf40448bb3cbd59668f316c7e5a3809a
Author: Yuming Wang <yumwang@...>
Date:   2018-09-14T08:23:50Z

    Support truncate number

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to