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

    https://github.com/apache/spark/pull/14788#discussion_r76041561
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
 ---
    @@ -783,27 +783,34 @@ case class TimeSub(start: Expression, interval: 
Expression)
     /**
      * Returns the date that is num_months after start_date.
      */
    +// scalastyle:off line.size.limit
     @ExpressionDescription(
    -  usage = "_FUNC_(start_date, num_months) - Returns the date that is 
num_months after start_date.",
    +  usage = "_FUNC_(start_date, num_months) - Returns the date/timestamp 
that is num_months after start_date.",
       extended = "> SELECT _FUNC_('2016-08-31', 1);\n '2016-09-30'")
    +// scalastyle:on line.size.limit
     case class AddMonths(startDate: Expression, numMonths: Expression)
       extends BinaryExpression with ImplicitCastInputTypes {
     
       override def left: Expression = startDate
       override def right: Expression = numMonths
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(DateType, 
IntegerType)
    +  override def inputTypes: Seq[AbstractDataType] =
    +    Seq(TypeCollection(DateType, TimestampType), IntegerType)
     
    -  override def dataType: DataType = DateType
    +  override def dataType: DataType = startDate.dataType
     
    -  override def nullSafeEval(start: Any, months: Any): Any = {
    -    DateTimeUtils.dateAddMonths(start.asInstanceOf[Int], 
months.asInstanceOf[Int])
    +  override def nullSafeEval(start: Any, months: Any): Any = 
startDate.dataType match {
    --- End diff --
    
    You could also add the parameters `start` and `months` to the pattern 
match.  That saves some casting.


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