[SPARK-57178][SQL] Simplify Asinh codegen by extracting a static Java helper#56229
Open
gengliangwang wants to merge 1 commit into
Open
[SPARK-57178][SQL] Simplify Asinh codegen by extracting a static Java helper#56229gengliangwang wants to merge 1 commit into
gengliangwang wants to merge 1 commit into
Conversation
… helper ### What changes were proposed in this pull request? Add `ExpressionImplUtils.asinh(double x)` (the fdlibm `s_asinh.c` algorithm) and route `Asinh`'s eval and codegen paths through it. `Asinh.doGenCode` previously emitted a ~14-line inline five-branch if/else; it now emits a single `ExpressionImplUtils.asinh(...)` call via `defineCodeGen`, and the eval path calls the same helper instead of an inline lambda copy of the algorithm. `asinh` returns a primitive `double`, so the helper is a clean drop-in for both paths with no boxing and no null handling. Sibling of SPARK-57177 (Acosh). ### Why are the changes needed? Part of SPARK-56908 (umbrella). Collapsing the duplicated ~14-line algorithm to a single call shrinks the generated Java for every stage that uses `asinh`, and removes the eval/codegen duplication of the same fdlibm algorithm. ### Does this PR introduce _any_ user-facing change? No. The compiled behavior is identical; only the emitted Java source text changes. ### How was this patch tested? ``` build/sbt "catalyst/testOnly *MathExpressionsSuite" ``` Pass, including `asinh` and `SPARK-56089: asinh/acosh fdlibm algorithm coverage` (exercised both with and without whole-stage codegen). ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.8) Co-authored-by: Isaac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add
ExpressionImplUtils.asinh(double x)(the fdlibms_asinh.calgorithm) and routeAsinh's eval and codegen paths through it.Asinh.doGenCodepreviously emitted a ~14-line inline five-branch if/else; it now emits a singleExpressionImplUtils.asinh(...)call viadefineCodeGen, and the eval path calls the same helper instead of an inline lambda copy of the algorithm.asinhreturns a primitivedouble, so the helper is a clean drop-in for both paths with no boxing and no null handling. Sibling of SPARK-57177 (Acosh).Why are the changes needed?
Part of SPARK-56908 (umbrella). Collapsing the duplicated ~14-line algorithm to a single call shrinks the generated Java for every stage that uses
asinh, and removes the eval/codegen duplication of the same fdlibm algorithm, helping with the JVM 64KB method / constant-pool limits, Janino compile time, and JIT work.Does this PR introduce any user-facing change?
No. The compiled behavior is identical; only the emitted Java source text changes.
How was this patch tested?
Pass, including
asinhandSPARK-56089: asinh/acosh fdlibm algorithm coverage(exercised both with and without whole-stage codegen).Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)