hvanhovell commented on a change in pull request #22054: [SPARK-24703][SQL]:
To add support to multiply CalendarInterval with Integral Type.
URL: https://github.com/apache/spark/pull/22054#discussion_r296404378
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
##########
@@ -222,6 +222,36 @@ case class Multiply(left: Expression, right: Expression)
extends BinaryArithmeti
protected override def nullSafeEval(input1: Any, input2: Any): Any =
numeric.times(input1, input2)
}
+@ExpressionDescription(
+ usage = "expr1 _FUNC_ expr2 - Returns `expr1`*`expr2`.",
+ examples = """
+ Examples:
+ > interval '1' day * 3
+ interval 3 days
+ """)
+case class MultiplyInterval(interval: Expression, multiplier: Expression)
+ extends BinaryExpression with ImplicitCastInputTypes {
+
+ override def left: Expression = interval
+ override def right: Expression = multiplier
+
+ override def inputTypes: Seq[AbstractDataType] = Seq(CalendarIntervalType,
IntegerType)
+
+ override def dataType: DataType = CalendarIntervalType
+
+ override def nullSafeEval(interval: Any, multiplier: Any): Any = {
+
interval.asInstanceOf[CalendarInterval].multiply(multiplier.asInstanceOf[Integer])
+ }
+
+ override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
+ nullSafeCodeGen(ctx, ev,
Review comment:
Can you add a test to `DateExpressionSuite`?
----------------------------------------------------------------
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]