cloud-fan commented on a change in pull request #33076:
URL: https://github.com/apache/spark/pull/33076#discussion_r658484299
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
##########
@@ -1446,23 +1451,25 @@ case class TimeAdd(start: Expression, interval:
Expression, timeZoneId: Option[S
override def toString: String = s"$left + $right"
override def sql: String = s"${left.sql} + ${right.sql}"
override def inputTypes: Seq[AbstractDataType] =
- Seq(TimestampType, TypeCollection(CalendarIntervalType,
DayTimeIntervalType))
+ Seq(TypeCollection.AllTimestampTypes, TypeCollection(CalendarIntervalType,
DayTimeIntervalType))
- override def dataType: DataType = TimestampType
+ override def dataType: DataType = start.dataType
override def withTimeZone(timeZoneId: String): TimeZoneAwareExpression =
copy(timeZoneId = Option(timeZoneId))
+ @transient private lazy val zoneIdInEval: ZoneId =
zoneIdForType(left.dataType)
+
override def nullSafeEval(start: Any, interval: Any): Any = right.dataType
match {
case _: DayTimeIntervalType =>
- timestampAddDayTime(start.asInstanceOf[Long],
interval.asInstanceOf[Long], zoneId)
+ timestampAddDayTime(start.asInstanceOf[Long],
interval.asInstanceOf[Long], zoneIdInEval)
case CalendarIntervalType =>
val i = interval.asInstanceOf[CalendarInterval]
- timestampAddInterval(start.asInstanceOf[Long], i.months, i.days,
i.microseconds, zoneId)
+ timestampAddInterval(start.asInstanceOf[Long], i.months, i.days,
i.microseconds, zoneIdInEval)
}
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
- val zid = ctx.addReferenceObj("zoneId", zoneId, classOf[ZoneId].getName)
+ val zid = ctx.addReferenceObj("zoneIdInEval", zoneIdInEval,
classOf[ZoneId].getName)
Review comment:
nit: in generated java code the variable name can still be `zoneId`
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]