[SPARK-20909][SQL] Add build-int SQL function - DAYOFWEEK#18134
[SPARK-20909][SQL] Add build-int SQL function - DAYOFWEEK#18134wangyum wants to merge 4 commits intoapache:masterfrom wangyum:SPARK-20909
Conversation
|
Test build #77478 has finished for PR 18134 at commit
|
ueshin
left a comment
There was a problem hiding this comment.
LGTM except for a minor comment.
|
|
||
| select to_timestamp(null), to_timestamp('2016-12-31 00:12:00'), to_timestamp('2016-12-31', 'yyyy-MM-dd'); | ||
|
|
||
| select dayofweek('2007-02-03'), dayofweek('2009-07-30'), dayofweek('2017-05-27'), dayofweek(null), dayofweek('1582-10-15 13:10:15'); No newline at end of file |
There was a problem hiding this comment.
nit: Can you add a line break at the end of file?
|
|
||
| override protected def nullSafeEval(date: Any): Any = { | ||
| c.setTimeInMillis(date.asInstanceOf[Int] * 1000L * 3600L * 24L) | ||
| c.get(Calendar.DAY_OF_WEEK) |
There was a problem hiding this comment.
In WeekOfYear, we set Calendar.MONDAY as the first day of a week. Here seems we assume it's Calendar.SUNDAY. Is there any conflict we will encounter?
| } | ||
| } | ||
|
|
||
| // scalastyle:off line.size.limit |
There was a problem hiding this comment.
As Sunday, Saturday are included, it is not only weekday. Returns the day of the week ....
|
LGTM except for one comment about the function description. |
|
Test build #77514 has finished for PR 18134 at commit
|
|
Test build #77513 has finished for PR 18134 at commit
|
|
Test build #77515 has finished for PR 18134 at commit
|
|
Thanks! Merging to master. |
|
@ueshin This function is not reported in the API documentation: https://spark.apache.org/docs/2.2.0/api/java/index.html?org/apache/spark/sql/functions.html or https://spark.apache.org/docs/2.1.0/api/java/index.html?org/apache/spark/sql/functions.html ? |
|
@sergiobilello-eb This is just a SQL function. You can call it in SQL interface or using the |
|
thanks @gatorsmile :) how can I call it from spark-sql? |
|
|
https://issues.apache.org/jira/browse/SPARK-20909 This is not part of 2.2. Based on JIRA, it will be included in 2.3 |
|
thanks @gatorsmile! Do you suggest any workaround until then? I mean not rebuilding spark with that patch.... Can I register my UDF that contains that logic? |
|
Yeah, you always can implement such a UDF. |
What changes were proposed in this pull request?
Add build-int SQL function - DAYOFWEEK
How was this patch tested?
unit tests