cloud-fan 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_r353550165
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -151,17 +151,18 @@ case class CurrentBatchTimestamp(
""",
since = "1.5.0")
case class DateAdd(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.toString.toInt
Review comment:
this is inefficient. How about `d.asInstanceOf[Number].intValue`
----------------------------------------------------------------
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]