You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "gengliangwang (via GitHub)" <gi...@apache.org> on 2026/05/22 12:56:31 UTC
[PR] [SPARK-57004][SQL] Simplify CheckOverflowInSum codegen under ANSI mode [spark]
gengliangwang opened a new pull request, #56063:
URL: https://github.com/apache/spark/pull/56063
### What changes were proposed in this pull request?
Introduce `DecimalExpressionUtils.java` with a `checkOverflowInSum(Decimal, int, int, boolean, QueryContext)` static helper and call it from `CheckOverflowInSum.doGenCode` and the eval path.
Codegen body shrinks from a 10-line if/else block (init `ev.value` to null, branch on `childGen.isNull`, conditionally throw, conditionally call `toPrecision` + re-set `ev.isNull`) to 4 lines (single helper call + post-check). Eval is now a single delegating call.
### Why are the changes needed?
Part of SPARK-56908 (umbrella). `CheckOverflowInSum` is emitted around every decimal `Sum` and is one of the longer remaining inline ANSI bodies. Collapsing the per-call-site body shrinks generated Java source and Janino compile time on aggregation-heavy plans.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
```
build/sbt "catalyst/testOnly *DecimalExpressionSuite *AggregateExpressionSuite"
build/sbt "sql/testOnly *DataFrameAggregateSuite -- -z sum"
```
20/20 pass (incl. the SPARK-39208 `CheckOverflowInSum` runtime-context test).
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor 1.x
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57004][SQL] Simplify CheckOverflowInSum codegen under ANSI mode [spark]
Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on PR #56063:
URL: https://github.com/apache/spark/pull/56063#issuecomment-4523600052
---
### Stack overview (SPARK-56908 umbrella)
This PR is part of the SPARK-56908 codegen-simplification series. Current status:
**Merged:**
- #55934 — [SPARK-56909][SQL] Simplify Cast to int/long codegen under ANSI mode
- #55938 — [SPARK-56913][SQL] Simplify BinaryArithmetic byte/short codegen under ANSI mode
- #55940 — [SPARK-56915][SQL] Simplify MakeDate/MakeInterval codegen under ANSI mode
- #55941 — [SPARK-56916][SQL] Simplify ElementAt array codegen under ANSI mode
- #55973 — [SPARK-56935][SQL] Simplify GetArrayItem codegen and consolidate ElementAtUtils into ArrayExpressionUtils
**Open:**
- #55935 — [SPARK-56910][SQL] Simplify Cast to byte/short codegen under ANSI mode *(branches off master)*
- #55936 — [SPARK-56911][SQL] Simplify Cast to decimal codegen under ANSI mode *(stacked on #55935)*
- #55937 — [SPARK-56912][SQL] Simplify Cast to boolean codegen under ANSI mode *(stacked on #55936)*
- #55939 — [SPARK-56914][SQL] Simplify decimal arithmetic codegen under ANSI mode *(stacked on #55936)*
- #56063 — [SPARK-57004][SQL] Simplify CheckOverflowInSum codegen under ANSI mode *(independent)*
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57004][SQL] Simplify CheckOverflowInSum codegen under ANSI mode [spark]
Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang closed pull request #56063: [SPARK-57004][SQL] Simplify CheckOverflowInSum codegen under ANSI mode
URL: https://github.com/apache/spark/pull/56063
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-57004][SQL] Simplify CheckOverflowInSum codegen under ANSI mode [spark]
Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on PR #56063:
URL: https://github.com/apache/spark/pull/56063#issuecomment-4579639681
@viirya thanks for the review. Merging to master/4.x
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org