yyanyy opened a new pull request, #60358: URL: https://github.com/apache/spark/pull/60358
### What changes were proposed in this pull request? Reject NULL elements in the constant array argument of all `kll_sketch_get_quantile_*` and `kll_sketch_get_rank_*` functions during analysis, using `DATATYPE_MISMATCH.UNEXPECTED_NULL`. The check inspects actual array elements after ordinary input type validation, rather than rejecting an array just because its type permits NULLs. Scalar NULL, whole-array NULL, empty arrays, valid arrays, and the non-nullable result element type remain unchanged. ### Why are the changes needed? The getters declare non-null array element types, but input type matching ignores array nullability. Their evaluation paths then read NULL slots as primitive numbers. For example, with a sketch containing 10, 20 and 30, `kll_sketch_get_quantile_bigint(sketch, array(0.5D, NULL))` can return the minimum in the NULL slot instead of rejecting the invalid request. Rank getters have the same problem. ### Does this PR introduce _any_ user-facing change? Yes. Constant request arrays containing NULL now produce an analysis error instead of silently returning a numeric answer for the NULL element. Valid inputs and scalar NULL propagation are unchanged. ### How was this patch tested? - Added parameterized Catalyst coverage for all six getters, NULLs at the beginning/middle/end and all-NULL arrays, typed/cast NULLs, valid nullable-typed arrays, empty arrays, scalar and whole-array NULL, scalar results, non-foldable arguments, and invalid input types. - Before production changes, `build/sbt 'catalyst/testOnly *MiscExpressionsSuite -- -z KLL'` ran 12 tests: the six NULL-element rejection tests failed and six compatibility tests passed. - After the fix, `build/sbt 'catalyst/testOnly *MiscExpressionsSuite'` passed all 22 tests. Catalyst production and test scalastyle passed. - Added end-to-end SQL regression coverage for all six getters in `kllquantiles.sql`. - Regenerated execution and analyzer goldens with `SQLQueryTestSuite`, inspected that all six new queries report `DATATYPE_MISMATCH.UNEXPECTED_NULL`, then passed the ordinary non-generation run (2 tests). - `build/sbt 'sql/testOnly *DataFrameAggregateSuite -- -z kll'` passed all 16 surrounding KLL tests. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex CLI 0.166.0 -- 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]
