c21 commented on a change in pull request #34670:
URL: https://github.com/apache/spark/pull/34670#discussion_r753528003
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
##########
@@ -1547,14 +1547,25 @@ case class BRound(child: Expression, scale: Expression)
}
object WidthBucket {
-
def computeBucketNumber(value: Double, min: Double, max: Double, numBucket:
Long): jl.Long = {
- if (numBucket <= 0 || numBucket == Long.MaxValue || jl.Double.isNaN(value)
|| min == max ||
- jl.Double.isNaN(min) || jl.Double.isInfinite(min) ||
- jl.Double.isNaN(max) || jl.Double.isInfinite(max)) {
- return null
+ if (isNull(value, min, max, numBucket)) {
+ null
+ } else {
+ computeBucketNumberNotNull(value, min, max, numBucket)
}
+ }
+ def isNull(value: Double, min: Double, max: Double, numBucket: Long):
Boolean = {
Review comment:
Sorry yeah you are right. Shall we add a comment for both `isNull` and
`computeBucketNumberNotNull` to explain it?
```
/**
* This is called by generated Java class, should be public.
*/
```
Similar to
[`HashAggregateExec`](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala#L426-L429).
--
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]