AngersZhuuuu commented on a change in pull request #32645:
URL: https://github.com/apache/spark/pull/32645#discussion_r651423198



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala
##########
@@ -345,6 +346,66 @@ case class MakeInterval(
     )
 }
 
+// scalastyle:off line.size.limit
+@ExpressionDescription(
+  usage = "_FUNC_(years, months) - Make year-month interval from years, 
months.",
+  arguments = """
+    Arguments:
+      * years - the number of years, positive or negative
+      * months - the number of months, positive or negative
+  """,
+  examples = """
+    Examples:
+      > SELECT _FUNC_(1, 2);
+       1-2
+      > SELECT _FUNC_(1, 0);
+       1-0
+      > SELECT _FUNC_(0, 1);
+       0-1
+  """,
+  since = "3.2.0",
+  group = "datetime_funcs")
+// scalastyle:on line.size.limit
+case class MakeYMInterval(years: Expression, months: Expression)
+  extends BinaryExpression with ImplicitCastInputTypes with NullIntolerant {
+
+  def this(years: Expression) = this(years, Literal(0))
+  def this() = this(Literal(0))
+
+  override def left: Expression = years
+  override def right: Expression = months
+  override def inputTypes: Seq[AbstractDataType] = Seq(IntegerType, 
IntegerType)
+  override def dataType: DataType = YearMonthIntervalType
+  override def nullable: Boolean = children.exists(_.nullable)
+
+  private def evalIntValue(dt: DataType, value: Any): Long = dt match {
+    case _: ByteType | _: ShortType | _: IntegerType => 
value.asInstanceOf[Number].longValue()

Review comment:
       We should handle it like `MultiplyYMInterval` use  `NumericType`?




-- 
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to