sathiyapk commented on a change in pull request #34729:
URL: https://github.com/apache/spark/pull/34729#discussion_r780514098
##########
File path:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MathExpressionsSuite.scala
##########
@@ -658,6 +669,62 @@ class MathExpressionsSuite extends SparkFunSuite with
ExpressionEvalHelper {
val intResultsB: Seq[Int] = Seq(314000000, 314200000, 314160000,
314159000, 314159300,
314159260) ++ Seq.fill(7)(314159265)
+ def doubleResultsFloor(i: Int): Any = {
+ val results = Seq(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3,
+ 3.1, 3.14, 3.141, 3.1415, 3.14159, 3.141592)
+ if (i <= 6) results(i).toLong else results(i)
+ }
+
+ def doubleResultsCeil(i: Int): Any = {
+ val results = Seq(1000000.0, 100000.0, 10000.0, 1000.0, 100.0, 10.0,
+ 4L, 3.2, 3.15, 3.142, 3.1416, 3.1416, 3.141593)
+ if (i <= 6) results(i).toLong else results(i)
+ }
+
+ def floatResultsFloor(i: Int): Any = {
+ val results = Seq(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3L,
+ 3.1d, 3.14d, 3.141d, 3.1414d, 3.14149d, 3.141499d)
+ if (i <= 6) results(i).toLong else results(i)
+ }
+
+ def floatResultsCeil(i: Int): Any = {
+ val results = Seq(1000000.0f, 100000.0f, 10000.0f, 1000.0f, 100.0f,
10.0f,
+ 4L, 3.2d, 3.15d, 3.142d, 3.1415d, 3.1415d, 3.1415d)
+ if (i <= 6) results(i).toLong else results(i)
+ }
+
+ def shortResultsFloor(i: Int): Any = {
+ val results = Seq[Long](0L, 0L, 30000L, 31000L,
+ 31400L, 31410L, 31415L) ++ Seq.fill[Long](7)(31415)
+ results(i)
+ }
+
+ def shortResultsCeil(i: Int): Any = {
Review comment:
Sorry, i am not sure i got it right.
Actually we test `RoundCeil` and `RoundFloor` directly for positive `scale`
on big decimal, i can add long and double in that case, if you prefer. But we
can't test `RoundCeil` and `RoundFloor` directly for negative `scale` because
the casting to `Long` for negative scale happens one step before.
May be if put the casting in the `RoundCeil` and `RoundFloor` objects and
let the `ExpressionBuilder` call these objects like it was before, we can able
to test `RoundCeil` and `RoundFloor` directly for both negative and positive
`scale`. What do you say ?
--
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]