sathiyapk commented on a change in pull request #34729:
URL: https://github.com/apache/spark/pull/34729#discussion_r760536604



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
##########
@@ -243,40 +243,26 @@ case class Cbrt(child: Expression) extends 
UnaryMathExpression(math.cbrt, "CBRT"
   examples = """
     Examples:
       > SELECT _FUNC_(-0.1);
-       0
+       0.0
       > SELECT _FUNC_(5);

Review comment:
       @cloud-fan @gengliangwang  For the Float and Double type during 
ROUND_CEILING and ROUND_FLOOR with scale 0, shall we cast the output type to 
Long ? This will preserve the default behavior of `floor`/`ceil`. Please let me 
know your opinion.
   
   something like this :
   ```
     def castOutputToLong: Boolean = Seq(ROUND_CEILING, 
ROUND_FLOOR).contains(mode) && _scale == 0
   
        ...
     def nullSafeEval(input1: Any): Any = {
       dataType match {
         ...
   
         case FloatType =>
           val f = input1.asInstanceOf[Float]
           val output = if (f.isNaN || f.isInfinite) {
             f
           } else {
             BigDecimal(f.toDouble).setScale(_scale, mode)
           }
           if(castOutputToLong) output.toLong else output.toShort
   
         case DoubleType =>
           val d = input1.asInstanceOf[Double]
           val output = if (d.isNaN || d.isInfinite) {
             d
           } else {
             BigDecimal(d).setScale(_scale, mode)
           }
           if(castOutputToLong) output.toLong else output.toShort
       }
     }
   ```




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to