fix: Update TPC-DS q36a golden file for Spark 4.0 decimal UNION widening change#3915
Open
parthchandra wants to merge 4 commits intoapache:mainfrom
Open
fix: Update TPC-DS q36a golden file for Spark 4.0 decimal UNION widening change#3915parthchandra wants to merge 4 commits intoapache:mainfrom
parthchandra wants to merge 4 commits intoapache:mainfrom
Conversation
parthchandra
commented
Apr 8, 2026
spark/src/test/scala/org/apache/spark/sql/CometTPCDSQueryTestSuite.scala
Show resolved
Hide resolved
mbutrovich
approved these changes
Apr 8, 2026
Contributor
mbutrovich
left a comment
There was a problem hiding this comment.
Thanks for the detailed PR description. This sounds like it was a journey to track down. Thanks @parthchandra!
Contributor
Author
|
Oh. Now the schema fails for pre-4.0 versions of Spark. So now we need a version specific set of golden files! |
Contributor
Author
|
@mbutrovich thank you for the approval, but if you don't mind taking another look. I changed the implementation so that there is a version specific result file. Since only the one query is affected, there is only one additional file. |
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.
Which issue does this PR close?
Running TPC-DS resulted in a schema mismatch error in q36a-v2.7
Rationale for this change
The golden file for TPC-DS v2.7 query q36a was originally generated against Spark 3.4, where DecimalPrecisionTypeCoercion.bounded() simply clamped precision/scale to the maximum (min(p, 38), min(s, 38)). This caused the UNION of decimal(37,20) and decimal(38,11) (the two branches of results_rollup) to widen to decimal(38,20).
SPARK-45905 changed the decimal least-common-type algorithm to prefer retaining integral digits over fractional digits when precision exceeds 38. The same UNION now correctly widens to decimal(38,11). Apache Spark's own TPCDSQueryTestSuite golden file reflects this.
What changes are included in this PR?
This adds a version specific golden file against Spark 4 to match the updated behavior. Also, decimal tests now also check that the schema matches with the one output by Spark.
How are these changes tested?
Running TPC-DS queries in
CometTPCDSQueryBenchmark. Also unit tests.