-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-15241][SPARK-15242][SQL] fix 2 decimal-related issues in RowEncoder #13019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
Contributor
Author
|
Test build #58202 has finished for PR 13019 at commit
|
Contributor
|
actually cc @davies also |
| .add("int", IntegerType) | ||
| .add("string", StringType) | ||
| .add("double", DoubleType) | ||
| .add("decimal", DecimalType.SYSTEM_DEFAULT) |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it is still good to keep int, string, and double columns?
Member
|
LGTM |
|
Test build #58339 has finished for PR 13019 at commit
|
Contributor
|
LGTM |
Contributor
|
Merging this into master and 2.0, thanks! |
asfgit
pushed a commit
that referenced
this pull request
May 11, 2016
…Encoder ## What changes were proposed in this pull request? SPARK-15241: We now support java decimal and catalyst decimal in external row, it makes sense to also support scala decimal. SPARK-15242: This is a long-standing bug, and is exposed after #12364, which eliminate the `If` expression if the field is not nullable: ``` val fieldValue = serializerFor( GetExternalRowField(inputObject, i, externalDataTypeForInput(f.dataType)), f.dataType) if (f.nullable) { If( Invoke(inputObject, "isNullAt", BooleanType, Literal(i) :: Nil), Literal.create(null, f.dataType), fieldValue) } else { fieldValue } ``` Previously, we always use `DecimalType.SYSTEM_DEFAULT` as the output type of converted decimal field, which is wrong as it doesn't match the real decimal type. However, it works well because we always put converted field into `If` expression to do the null check, and `If` use its `trueValue`'s data type as its output type. Now if we have a not nullable decimal field, then the converted field's output type will be `DecimalType.SYSTEM_DEFAULT`, and we will write wrong data into unsafe row. The fix is simple, just use the given decimal type as the output type of converted decimal field. These 2 issues was found at #13008 ## How was this patch tested? new tests in RowEncoderSuite Author: Wenchen Fan <wenchen@databricks.com> Closes #13019 from cloud-fan/encoder-decimal. (cherry picked from commit d8935db) Signed-off-by: Davies Liu <davies.liu@gmail.com>
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?
SPARK-15241: We now support java decimal and catalyst decimal in external row, it makes sense to also support scala decimal.
SPARK-15242: This is a long-standing bug, and is exposed after #12364, which eliminate the
Ifexpression if the field is not nullable:Previously, we always use
DecimalType.SYSTEM_DEFAULTas the output type of converted decimal field, which is wrong as it doesn't match the real decimal type. However, it works well because we always put converted field intoIfexpression to do the null check, andIfuse itstrueValue's data type as its output type.Now if we have a not nullable decimal field, then the converted field's output type will be
DecimalType.SYSTEM_DEFAULT, and we will write wrong data into unsafe row.The fix is simple, just use the given decimal type as the output type of converted decimal field.
These 2 issues was found at #13008
How was this patch tested?
new tests in RowEncoderSuite