Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-37475

Add Scale Parameter to Floor and Ceil functions

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.2.0
    • 3.3.0
    • SQL
    • None

    Description

      This feature is proposed in the PR : https://github.com/apache/spark/pull/34593

      Currently we support Decimal RoundingModes : HALF_UP (round) and HALF_EVEN (bround). But we have use cases that needs RoundingMode.UP and RoundingMode.DOWN.

      https://stackoverflow.com/questions/34888419/round-down-double-in-spark/40476117

      https://stackoverflow.com/questions/54683066/is-there-a-rounddown-function-in-sql-as-there-is-in-excel

      https://stackoverflow.com/questions/48279641/oracle-sql-round-half

       

      Floor and Ceil functions helps to do this but it doesn't support the position of the rounding. Adding scale parameter to the functions would help us control the rounding positions. 

       

      Snowflake supports `scale` parameter to `floor`/`ceil` :

      FLOOR( <input_expr> [, <scale_expr> ] )

      REF:

      https://docs.snowflake.com/en/sql-reference/functions/floor.html

       

       

       

       

      Attachments

        Activity

          People

            Sathiya Sathiya Kumar
            Sathiya Sathiya Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: