zhengruifeng opened a new pull request, #47970:
URL: https://github.com/apache/spark/pull/47970
### What changes were proposed in this pull request?
Apply `ArrayBinarySearch` for histogram
### Why are the changes needed?
this expression is dedicated for histogram, and supports codegen
```
(5) Project [codegen id : 1]
Output [2]: [__group_id#37, cast(CASE WHEN ((__value#38 >= 1.0) AND
(__value#38 <= 12.0)) THEN CASE WHEN (__value#38 = 12.0) THEN 11 WHEN
(static_invoke(ArrayExpressionUtils.binarySearchNullSafe([1.0,1.9166666666666665,2.833333333333333,3.75,4.666666666666666,5.583333333333333,6.5,7.416666666666666,8.333333333333332,9.25,10.166666666666666,11.083333333333332,12.0],
__value#38)) > 0) THEN
static_invoke(ArrayExpressionUtils.binarySearchNullSafe([1.0,1.9166666666666665,2.833333333333333,3.75,4.666666666666666,5.583333333333333,6.5,7.416666666666666,8.333333333333332,9.25,10.166666666666666,11.083333333333332,12.0],
__value#38)) ELSE
(-static_invoke(ArrayExpressionUtils.binarySearchNullSafe([1.0,1.9166666666666665,2.833333333333333,3.75,4.666666666666666,5.583333333333333,6.5,7.416666666666666,8.333333333333332,9.25,10.166666666666666,11.083333333333332,12.0],
__value#38)) - 2) END WHEN isnan(__value#38) THEN
cast(raise_error(USER_RAISED_EXCEPTION, map(keys: [errorMessage], values: [H
istogram encountered NaN value.]), NullType) as int) ELSE
cast(raise_error(USER_RAISED_EXCEPTION, map(errorMessage, printf(value %s out
of the bins bounds: [%s, %s], __value#38, 1.0, 12.0)), NullType) as int) END as
double) AS __bucket#46]
Input [2]: [__group_id#37, __value#38]
```
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
CI and manually check
### Was this patch authored or co-authored using generative AI tooling?
No
--
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]