You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/10/12 16:40:02 UTC

[GitHub] [spark] MaxGekk commented on a change in pull request #34256: [SPARK-36922][SQL] The SIGN/SIGNUM functions should support ANSI intervals

MaxGekk commented on a change in pull request #34256:
URL: https://github.com/apache/spark/pull/34256#discussion_r727315953



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
##########
@@ -658,6 +658,13 @@ case class Rint(child: Expression) extends UnaryMathExpression(math.rint, "ROUND
   since = "1.4.0",
   group = "math_funcs")
 case class Signum(child: Expression) extends UnaryMathExpression(math.signum, "SIGNUM") {
+  override def inputTypes: Seq[AbstractDataType] =
+    Seq(TypeCollection(DoubleType, YearMonthIntervalType, DayTimeIntervalType))
+  protected override def nullSafeEval(input: Any): Any = child.dataType match {

Review comment:
       I think we could avoid checking the type in runtime completely:
   ```scala
     protected override def nullSafeEval(input: Any): Any = {
       f(input.asInstanceOf[Number].doubleValue())
     }
   ```




-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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