fix(spark): report interval_year overflow instead of wrapping - #1140
Open
alexandrefimov wants to merge 1 commit into
Open
fix(spark): report interval_year overflow instead of wrapping#1140alexandrefimov wants to merge 1 commit into
alexandrefimov wants to merge 1 commit into
Conversation
years and months are both int32 on the wire and Spark's physical type is a months Int, so nothing widens the arithmetic the way the day-time literal is widened. Above 178,956,970 years the product wrapped, and a large positive interval came out negative — Int.MaxValue years became -12 months. Far outside the spec's 10,000-year bound, so it takes a producer that is already well past it; the point is that the two adjacent literal conversions now take the same stance on the same arithmetic.
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.
ToSparkExpression.visit(IntervalYearLiteral)flattened years and months with uncheckedIntarithmetic. Both operands areint32on the wire and Spark's physical type is a monthsInt, so unlike the day-time case nothing widens the multiply: above 178,956,970 years it wrapped, and a large positive interval came out negative — 178,956,971 years as −2,147,483,644 months,Int.MaxValueyears as −12.Far outside the spec's 10,000-year bound, so it takes a producer already well past it, and #1129 remains the primary fix — a per-component check in
corewould make this unreachable rather than merely loud. What makes it worth fixing here anyway is that #1128 hardened the day-time literal eight lines above, so the two adjacent conversions in the same visitor took opposite stances on the same arithmetic.Closes #1138.