You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Jeff Zhang (JIRA)" <ji...@apache.org> on 2015/12/02 07:03:11 UTC
[jira] [Commented] (SPARK-12045) Use joda's DateTime to replace
Calendar
[ https://issues.apache.org/jira/browse/SPARK-12045?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15035333#comment-15035333 ]
Jeff Zhang commented on SPARK-12045:
------------------------------------
[~cloud_fan] I saw you are on the history of DateTimeUtils, so guess you might know the history of this file. I notice that there's some logic of parsing string to date, not sure why we don't use library instead, is there any case that the third party library can not handle ? Besides that I find one suspicious place as following. Why the millisecond should be 6 digits, as my understanding, it should only 3 digits right ?
Line 301 of DateTimeUtils
{code}
while (digitsMilli < 6) {
segments(6) *= 10
digitsMilli += 1
}
{code}
> Use joda's DateTime to replace Calendar
> ---------------------------------------
>
> Key: SPARK-12045
> URL: https://issues.apache.org/jira/browse/SPARK-12045
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 1.5.2
> Reporter: Jeff Zhang
>
> Currently spark use Calendar to build the Date when convert from string to Date. But Calendar can not detect the invalid date format (e.g. 2011-02-29).
> Although we can use Calendar.setLenient(false) to enable Calendar to detect the invalid date format, but found the error message very confusing. So I suggest to use joda's DateTime to replace Calendar.
> Besides that, I found that there's already some format checking logic when casting string to date. And if it is invalid format, it would return None. I don't think it make sense to just return None without telling users. I think by default should just throw exception, and user can set property to allow it return None if invalid format.
> {code}
> if (i == 0 && j != 4) {
> // year should have exact four digits
> return None
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org