You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/07/20 12:19:35 UTC

[GitHub] [spark] MaxGekk opened a new pull request #25210: [SPARK-28432][SQL] New function - make_date

MaxGekk opened a new pull request #25210: [SPARK-28432][SQL] New function - make_date
URL: https://github.com/apache/spark/pull/25210
 
 
   ## What changes were proposed in this pull request?
   
   New function `make_date()` takes 3 columns `year`, `month` and `day`, and makes new column of the `DATE` type. If values in the input columns are `null` or out of valid ranges, the function returns `null`. Valid ranges are:
   - `year` - `[1, 9999]`
   - `month` - `[1, 12]`
   - `day` - `[1, 31]`
   
   Also constructed date must be valid otherwise `make_date` returns `null`.
   
   Here is an example in Spark R:
   ```r
   > df <- createDataFrame(list(list(2019, 7, 20), list(2019, 7, 32)), c("year", "month", "day"))
   > res <- select(df, make_date(df$year, df$month, df$day))
   > schema(res)
   StructType
   |-name = "make_date(year, month, day)", type = "DateType", nullable = TRUE
   > collect(res)
     make_date(year, month, day)
   1                  2019-07-20
   2                        <NA>
   ```
   
   ## How was this patch tested?
   
   Added new tests to `DateExpressionsSuite` and `DateFunctionsSuite`, and code examples for SparkR/PySpark.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org