sadikovi commented on code in PR #37147:
URL: https://github.com/apache/spark/pull/37147#discussion_r928323688
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/UnivocityParser.scala:
##########
@@ -217,16 +234,17 @@ class UnivocityParser(
timestampFormatter.parse(datum)
} catch {
case NonFatal(e) =>
- // If fails to parse, then tries the way used in 2.0 and 1.x for
backwards
- // compatibility.
- val str =
DateTimeUtils.cleanLegacyTimestampStr(UTF8String.fromString(datum))
- DateTimeUtils.stringToTimestamp(str, options.zoneId).getOrElse {
- // There may be date type entries in timestamp column due to
schema inference
- if (options.inferDate) {
- daysToMicros(dateFormatter.parse(datum), options.zoneId)
- } else {
- throw(e)
+ // There may be date type entries in timestamp column due to
schema inference
+ if (options.inferDate) {
Review Comment:
This reorganisation is required to define priority of parsing timestamps as
dates when `inferDate = true`. Since this is optional, we try this first and
then fall back to the legacy behaviour if it is enabled.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/UnivocityParser.scala:
##########
@@ -217,16 +234,17 @@ class UnivocityParser(
timestampFormatter.parse(datum)
} catch {
case NonFatal(e) =>
- // If fails to parse, then tries the way used in 2.0 and 1.x for
backwards
- // compatibility.
- val str =
DateTimeUtils.cleanLegacyTimestampStr(UTF8String.fromString(datum))
- DateTimeUtils.stringToTimestamp(str, options.zoneId).getOrElse {
- // There may be date type entries in timestamp column due to
schema inference
- if (options.inferDate) {
- daysToMicros(dateFormatter.parse(datum), options.zoneId)
- } else {
- throw(e)
+ // There may be date type entries in timestamp column due to
schema inference
+ if (options.inferDate) {
Review Comment:
cc @cloud-fan @Jonathancui123
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]