[SPARK-28200][SQL] Decimal overflow handling in ExpressionEncoder#25016
[SPARK-28200][SQL] Decimal overflow handling in ExpressionEncoder#25016mickjermsurawong-stripe wants to merge 6 commits intoapache:masterfrom
Conversation
|
@mickjermsurawong-stripe, I think we also had a test case for |
|
jenkins this is ok to test |
There was a problem hiding this comment.
Seq("true", "false").foreach
|
Test build #107048 has finished for PR 25016 at commit
|
|
Test build #107052 has finished for PR 25016 at commit
|
There was a problem hiding this comment.
shall we use -BigDecimal... instead of .unary_-
mgaido91
left a comment
There was a problem hiding this comment.
mostly LGTM, just some style comments on the tests. Thanks.
Anyway, may you please also update the description of the PR? Because actually, the point here is not that we are not honoring the newly introduced flag, but previously we were not checking/handling at all the overflow in these situations. So I think we best should make this more clear in the PR description. Thanks.
There was a problem hiding this comment.
| withSQLConf(SQLConf.DECIMAL_OPERATIONS_NULL_ON_OVERFLOW.key -> true.toString) { | |
| withSQLConf(SQLConf.DECIMAL_OPERATIONS_NULL_ON_OVERFLOW.key -> "true") { |
There was a problem hiding this comment.
| withSQLConf(SQLConf.DECIMAL_OPERATIONS_NULL_ON_OVERFLOW.key -> false.toString) { | |
| withSQLConf(SQLConf.DECIMAL_OPERATIONS_NULL_ON_OVERFLOW.key -> "false") { |
There was a problem hiding this comment.
nit: may you please also add the Jira number to the test case? Thanks.
There was a problem hiding this comment.
Updated. thank you Marco!
|
Test build #107062 has finished for PR 25016 at commit
|
|
Test build #107081 has finished for PR 25016 at commit
|
|
thanks, merging to master! |
What changes were proposed in this pull request?
ExpressionEncoderdoes not handle bigdecimal overflow. Round-tripping overflowing java/scala BigDecimal/BigInteger returns null.changePrecisionwill be false and row has null value.spark/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/codegen/UnsafeRowWriter.java
Lines 202 to 206 in 24e1e41
ExpressionEncoderto throw when detecting overflowing BigDecimal/BigInteger before its corresponding Decimal gets written to Row. This gives a consistent behavior between decimal arithmetic on sql expression (DecimalPrecision), and getting decimal from dataframe (RowEncoder)Thanks to @mgaido91 for the very first PR
SPARK-23179and follow-up discussion on this change.Thanks to @JoshRosen for working with me on this.
How was this patch tested?
added unit tests