Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16138#discussion_r96722604
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
 ---
    @@ -1047,6 +1048,60 @@ case class ToDate(child: Expression) extends 
UnaryExpression with ImplicitCastIn
     }
     
     /**
    + * Parses a column to a date based on the given format.
    + */
    +@ExpressionDescription(
    +  usage = "_FUNC_(date_str, fmt) - Parses the `left` expression with the 
`fmt` expression.",
    +  extended = """
    +    Examples:
    +      > SELECT _FUNC_('2016-12-31', 'yyyy-MM-dd');
    +       2016-12-31
    +  """)
    +case class ParseToDate(left: Expression, format: Expression, child: 
Expression)
    +  extends RuntimeReplaceable {
    +
    +  def this(left: Expression, format: Expression) = {
    +    this(left, format, Cast(new ParseToTimestamp(left, format), DateType))
    +  }
    +
    +  def this(left: Expression) = {
    +    this(left, Literal(""), ToDate(left))
    +  }
    +
    +  override def flatArguments: Iterator[Any] = Iterator(left, format)
    +  override def sql: String = s"$prettyName(${left.sql}, ${format.sql})"
    +
    +  override def prettyName: String = "to_date"
    +  override def dataType: DataType = DateType
    +}
    +
    +/**
    + * Parses a column to a timestamp based on the supplied format.
    + */
    +// scalastyle:off line.size.limit
    +@ExpressionDescription(
    +  usage = "_FUNC_(timestamp, fmt) - Parses the `left` expression with the 
`format` expression to a timestamp.",
    --- End diff --
    
    Could you mention that this function will return null with the input is 
invalid.


---
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]

Reply via email to