Skip to content
  • anabranch's avatar
    7a7ce272
    [SPARK-16609] Add to_date/to_timestamp with format functions · 7a7ce272
    anabranch authored
    ## What changes were proposed in this pull request?
    
    This pull request adds two new user facing functions:
    - `to_date` which accepts an expression and a format and returns a date.
    - `to_timestamp` which accepts an expression and a format and returns a timestamp.
    
    For example, Given a date in format: `2016-21-05`. (YYYY-dd-MM)
    
    ### Date Function
    *Previously*
    ```
    to_date(unix_timestamp(lit("2016-21-05"), "yyyy-dd-MM").cast("timestamp"))
    ```
    *Current*
    ```
    to_date(lit("2016-21-05"), "yyyy-dd-MM")
    ```
    
    ### Timestamp Function
    *Previously*
    ```
    unix_timestamp(lit("2016-21-05"), "yyyy-dd-MM").cast("timestamp")
    ```
    *Current*
    ```
    to_timestamp(lit("2016-21-05"), "yyyy-dd-MM")
    ```
    ### Tasks
    
    - [X] Add `to_date` to Scala Functions
    - [x] Add `to_date` to Python Functions
    - [x] Add `to_date` to SQL Functions
    - [X] Add `to_timestamp` to Scala Functions
    - [x] Add `to_timestamp` to Python Functions
    - [x] Add `to_timestamp` to SQL Functions
    - [x] Add function to R
    
    ## How was this patch tested?
    
    - [x] Add Functions to `DateFunctionsSuite`
    - Test new `ParseToTimestamp` Expression (*not necessary*)
    - Test new `ParseToDate` Expression (*not necessary*)
    - [x] Add test for R
    - [x] Add test for Python in test.py
    
    Please review http://spark.apache.org/contributing.html before opening a pull request.
    
    Author: anabranch <wac.chambers@gmail.com>
    Author: Bill Chambers <bill@databricks.com>
    Author: anabranch <bill@databricks.com>
    
    Closes #16138 from anabranch/SPARK-16609.
    7a7ce272
    [SPARK-16609] Add to_date/to_timestamp with format functions
    anabranch authored
    ## What changes were proposed in this pull request?
    
    This pull request adds two new user facing functions:
    - `to_date` which accepts an expression and a format and returns a date.
    - `to_timestamp` which accepts an expression and a format and returns a timestamp.
    
    For example, Given a date in format: `2016-21-05`. (YYYY-dd-MM)
    
    ### Date Function
    *Previously*
    ```
    to_date(unix_timestamp(lit("2016-21-05"), "yyyy-dd-MM").cast("timestamp"))
    ```
    *Current*
    ```
    to_date(lit("2016-21-05"), "yyyy-dd-MM")
    ```
    
    ### Timestamp Function
    *Previously*
    ```
    unix_timestamp(lit("2016-21-05"), "yyyy-dd-MM").cast("timestamp")
    ```
    *Current*
    ```
    to_timestamp(lit("2016-21-05"), "yyyy-dd-MM")
    ```
    ### Tasks
    
    - [X] Add `to_date` to Scala Functions
    - [x] Add `to_date` to Python Functions
    - [x] Add `to_date` to SQL Functions
    - [X] Add `to_timestamp` to Scala Functions
    - [x] Add `to_timestamp` to Python Functions
    - [x] Add `to_timestamp` to SQL Functions
    - [x] Add function to R
    
    ## How was this patch tested?
    
    - [x] Add Functions to `DateFunctionsSuite`
    - Test new `ParseToTimestamp` Expression (*not necessary*)
    - Test new `ParseToDate` Expression (*not necessary*)
    - [x] Add test for R
    - [x] Add test for Python in test.py
    
    Please review http://spark.apache.org/contributing.html before opening a pull request.
    
    Author: anabranch <wac.chambers@gmail.com>
    Author: Bill Chambers <bill@databricks.com>
    Author: anabranch <bill@databricks.com>
    
    Closes #16138 from anabranch/SPARK-16609.
Loading