Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanbussel committed Nov 19, 2021
1 parent ed96fcc commit 0cba30d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -1555,6 +1555,7 @@ object WidthBucket {
}
}

/** This function is called by generated Java code, so it needs to be public. */
def isNull(value: Double, min: Double, max: Double, numBucket: Long): Boolean = {
numBucket <= 0 ||
numBucket == Long.MaxValue ||
Expand All @@ -1564,6 +1565,7 @@ object WidthBucket {
jl.Double.isNaN(max) || jl.Double.isInfinite(max)
}

/** This function is called by generated Java code, so it needs to be public. */
def computeBucketNumberNotNull(
value: Double, min: Double, max: Double, numBucket: Long): jl.Long = {
val lower = Math.min(min, max)
Expand Down
Expand Up @@ -771,8 +771,10 @@ class MathExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(WidthBucket(-0.9, 5.2, 0.5, 2L), 3L)
checkEvaluation(WidthBucket(nullDouble, 0.024, 10.06, 5L), null)
checkEvaluation(WidthBucket(5.35, nullDouble, 10.06, 5L), null)
checkEvaluation(WidthBucket(5.35, 0.024, nullDouble, -5L), null)
checkEvaluation(WidthBucket(5.35, 0.024, nullDouble, 5L), null)
checkEvaluation(WidthBucket(5.35, nullDouble, nullDouble, 5L), null)
checkEvaluation(WidthBucket(5.35, 0.024, 10.06, nullLong), null)
checkEvaluation(WidthBucket(nullDouble, nullDouble, nullDouble, nullLong), null)
checkEvaluation(WidthBucket(5.35, 0.024, 10.06, -5L), null)
checkEvaluation(WidthBucket(5.35, 0.024, 10.06, Long.MaxValue), null)
checkEvaluation(WidthBucket(Double.NaN, 0.024, 10.06, 5L), null)
Expand Down

0 comments on commit 0cba30d

Please sign in to comment.