cloud-fan commented on a change in pull request #31961:
URL: https://github.com/apache/spark/pull/31961#discussion_r602033028
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala
##########
@@ -341,3 +341,53 @@ case class MultiplyDTInterval(
override def toString: String = s"($left * $right)"
}
+
+// Divide an year-month interval by a numeric
+case class DivideYMInterval(
+ interval: Expression,
+ num: Expression)
+ extends BinaryExpression with ImplicitCastInputTypes with NullIntolerant
with Serializable {
+ override def left: Expression = interval
+ override def right: Expression = num
+
+ override def inputTypes: Seq[AbstractDataType] = Seq(YearMonthIntervalType,
NumericType)
+ override def dataType: DataType = YearMonthIntervalType
+
+ @transient
+ private lazy val evalFunc: (Int, Any) => Any = right.dataType match {
+ case LongType => (months: Int, num) =>
+ LongMath.divide(months, num.asInstanceOf[Long],
RoundingMode.HALF_UP).toInt
Review comment:
It's better to put it as a code comment. We can fix it in the next PR.
--
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]