Github user dongjoon-hyun commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22943#discussion_r230911108
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
 ---
    @@ -359,7 +359,7 @@ case class Cast(child: Expression, dataType: DataType, 
timeZoneId: Option[String
       // TimestampConverter
       private[this] def castToTimestamp(from: DataType): Any => Any = from 
match {
         case StringType =>
    -      buildCast[UTF8String](_, utfs => 
DateTimeUtils.stringToTimestamp(utfs, timeZone).orNull)
    +      buildCast[UTF8String](_, s => 
DateTimeUtils.stringToTimestamp(s.trim(), timeZone).orNull)
    --- End diff --
    
    What about changing `stringToDate` and `stringToTimestamp` instead?
    Those functions are used only in `Cast` and they already handle 
`null`cases, too.
    I didn't look at the detail of this PR. The change looks a little less 
robust when `s` is `null`.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to