Uh oh!
There was an error while loading. Please reload this page.
[SPARK-19228][SQL] Migrate on Java 8 time from FastDateFormat for meet the ISO8601 - #21363
[SPARK-19228][SQL] Migrate on Java 8 time from FastDateFormat for meet the ISO8601#21363sergey-rubtsov wants to merge 1 commit into
Conversation
…t the ISO8601 and parsing dates in csv correctly. Add support for inferring DateType and custom "dateFormat" option.
sergey-rubtsov
commented
May 18, 2018
Previous pull request #20140 is closed |
@HyukjinKwon, @gatorsmile please take a look |
sergey-rubtsov
commented
May 20, 2018
HyukjinKwon
commented
May 21, 2018
ok to test |
SparkQA
commented
May 21, 2018
Test build #90870 has finished for PR 21363 at commit
|
@sergey-rubtsov, would we be able to add a configuration to control this behaviour? Sounds we should better have a configuration to control this behaviour for now since the date / timestamp parsing logic is affected by the library change. |
| .atStartOfDay(options.timeZone.toZoneId) | ||
| .toInstant.toEpochMilli | ||
| val castedDate = | ||
| parser.makeConverter("_1", DateType, nullable = true, options = dateOptions) |
| val positiveInf = parameters.getOrElse("positiveInf", "Inf") | ||
| val negativeInf = parameters.getOrElse("negativeInf", "-Inf") | ||
| def dateTimeToMicroseconds(localDateTime: LocalDateTime, timeZone: TimeZone): Long = { | ||
| val microOfSecond = localDateTime.getLong(ChronoField.MICRO_OF_SECOND) | ||
| val epochSecond = localDateTime.atZone(timeZone.toZoneId).toInstant.getEpochSecond | ||
| epochSecond * 1000000L + microOfSecond |
| if ((allCatch opt field.toDouble).isDefined || isInfOrNan(field, options)) { | ||
| DoubleType | ||
| } else { | ||
| tryParseDate(field, options) |
There was a problem hiding this comment.
Is this a behavior change? Previously timestamp type, now date type/timestamp type?
There was a problem hiding this comment.
For example, by mistake we have identical "timestampFormat" and "dateFormat" options.
Let it be "yyyy-MM-dd"
'TimestampType' (8 bytes) is larger than 'DateType' (4 bytes)
So if they can overlap, we need to try parse it as date firstly, because both of these types are suitable, but you need to try to use a more compact by default and it will be correct inferring of type
There was a problem hiding this comment.
At the moment, DateType here is ignored at all, I'm not sure that it was conceived when the type was created
| test("Timestamp field types are inferred correctly via custom data format") { | ||
| var options = new CSVOptions(Map("timestampFormat" -> "yyyy-mm"), "GMT") | ||
| test("Timestamp field types are inferred correctly via custom date format") { | ||
| var options = new CSVOptions(Map("timestampFormat" -> "yyyy-MM"), "GMT") |
There was a problem hiding this comment.
Why we need to change this? The format string change is also a behavior change for users. We might need a config for that.
There was a problem hiding this comment.
"yyyy-mm" means years and minutes, this is a date format, not a time format
"yyyy-MM" means years and months, but I do not insist on this change
| // DecimalTypes have different precisions and scales, so we try to find the common type. | ||
| findTightestCommonType(typeSoFar, tryParseDecimal(field, options)).getOrElse(StringType) | ||
| case DoubleType => tryParseDouble(field, options) | ||
| case DateType => tryParseDate(field, options) |
There was a problem hiding this comment.
this also is a behavior change. Shall we document it?
There was a problem hiding this comment.
I can do it, but where exactly it should be documented?
sergey-rubtsov
commented
May 21, 2018
@HyukjinKwon please, clarify, how to add a configuration to control this behaviour? Do you mean to keep backward compatibility? |
mgaido91
commented
May 21, 2018
@sergey-rubtsov we have to keep backward compatibility. If a user upgrades, with your change a running application may break because of data not being anymore timestamp but date. We can add a new entry in Moreover, we have to mention in the migration guide all the behavioral changes we introduce. |
HyukjinKwon
commented
Jun 9, 2018
ok to test |
SparkQA
commented
Jun 9, 2018
Test build #91599 has finished for PR 21363 at commit
|
AmplabJenkins
commented
Oct 22, 2018
Can one of the admins verify this patch? |
srowen
left a comment
There was a problem hiding this comment.
I agree we can probably use Java 8 Date classes now instead of 3rd party ones, but can we do so without a behavior change? is it actually required?
HyukjinKwon
commented
Nov 9, 2018
Looks difficult because the behaviours themselves are different. One possibility is a fallback and the other possibility is configuration. |
HyukjinKwon
commented
Nov 11, 2018
I am going to suggest to close this since it's being active more then few weeks. It should be good to fix. Let me leave some cc's who might be interested in this just FYI. Feel free to take over this when you guys find some time or are interested in this. Adding @xuanyuanking, @mgaido91, @viirya, @MaxGekk, @softmanu who I could think of for now. Feel free to ignore my cc if you guys are busy or having more important fixes you guys are working on. |
xuanyuanking
commented
Nov 11, 2018
@HyukjinKwon Great thanks for ping me, I'll try to work on this and cc all reviewer in this PR. |
MaxGekk
commented
Nov 18, 2018
@xuanyuanking Are you still working on this? If not, I could continue. |
xuanyuanking
commented
Nov 19, 2018
@MaxGekk Sorry for the late, something inserted in the my scheduler, I plan to start this PR in this weekend, if its too late please just take it, sorry for the late again. |
MaxGekk
commented
Nov 26, 2018
Here is the PR: #23150 which allows to switch on java.time API (in CSV so far). |
srowen
commented
Dec 4, 2018
@MaxGekk now that your change is merge, can this proceed, @xuanyuanking ? or is it obsolete? |
MaxGekk
commented
Dec 4, 2018
HyukjinKwon
commented
Dec 18, 2018
I'm going to close this since @sergey-rubtsov is inactive. Most of feasible changes extracted from here are merged. One last part is date type inference which's going to need some more discussions (IMHO). |
What changes were proposed in this pull request?
Add support for inferring DateType and custom "dateFormat" option.
Fix an old bug with parse string to SQL's timestamp value in microseconds accuracy.
Add a type-widening rule in findTightestCommonType between DateType and TimestampType.
How was this patch tested?
Fix some tests to accord with an internationally agreed way to represent dates.
Add an end-to-end test case and unit tests.