Github user tarekauel commented on a diff in the pull request:
https://github.com/apache/spark/pull/7353#discussion_r34486426
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
---
@@ -165,15 +165,8 @@ case class Cast(child: Expression, dataType: DataType)
extends UnaryExpression w
private[this] def castToTimestamp(from: DataType): Any => Any = from
match {
case StringType =>
buildCast[UTF8String](_, utfs => {
- // Throw away extra if more than 9 decimal places
- val s = utfs.toString
- val periodIdx = s.indexOf(".")
- var n = s
- if (periodIdx != -1 && n.length() - periodIdx > 9) {
- n = n.substring(0, periodIdx + 10)
- }
- try DateTimeUtils.fromJavaTimestamp(Timestamp.valueOf(n))
- catch { case _: java.lang.IllegalArgumentException => null }
+ val parsedDateString = DateTimeUtils.stringToTimestamp(utfs)
+ if (parsedDateString == null) null else
DateTimeUtils.fromJavaTimestamp(parsedDateString)
--- End diff --
I'm going to adjust this.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]