yaooqinn commented on a change in pull request #26412: [SPARK-29774][SQL] Date
and Timestamp type +/- null should be null as Postgres
URL: https://github.com/apache/spark/pull/26412#discussion_r353588331
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -185,16 +186,17 @@ case class DateAdd(startDate: Expression, days:
Expression)
""",
since = "1.5.0")
case class DateSub(startDate: Expression, days: Expression)
- extends BinaryExpression with ImplicitCastInputTypes {
+ extends BinaryExpression with ExpectsInputTypes {
override def left: Expression = startDate
override def right: Expression = days
- override def inputTypes: Seq[AbstractDataType] = Seq(DateType, IntegerType)
+ override def inputTypes: Seq[AbstractDataType] =
+ Seq(DateType, TypeCollection(IntegerType, ShortType, ByteType))
override def dataType: DataType = DateType
override def nullSafeEval(start: Any, d: Any): Any = {
- start.asInstanceOf[Int] - d.asInstanceOf[Int]
+ start.asInstanceOf[Int] - d.asInstanceOf[Number].intValue()
Review comment:
done
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]