-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-10648] Proposed bug fix when oracle returns -127 as a scale to a numeric type #8780
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
Changes from all commits
b0c3be3
01b89bd
9b1d407
8f2f3fd
8110d30
d11141c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,9 +66,7 @@ private[sql] object JDBCRDD extends Logging { | |
| case java.sql.Types.CLOB => StringType | ||
| case java.sql.Types.DATALINK => null | ||
| case java.sql.Types.DATE => DateType | ||
| case java.sql.Types.DECIMAL | ||
| if precision != 0 || scale != 0 => DecimalType.bounded(precision, scale) | ||
| case java.sql.Types.DECIMAL => DecimalType.SYSTEM_DEFAULT | ||
| case java.sql.Types.DECIMAL => DecimalType.bounded(precision, scale) | ||
| case java.sql.Types.DISTINCT => null | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about change this to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That wouldn't work as demonstrated earlier in the thread. A negative scale is legal to reduce precision to the 10s place, 100s place, etc... |
||
| case java.sql.Types.DOUBLE => DoubleType | ||
| case java.sql.Types.FLOAT => FloatType | ||
|
|
@@ -80,9 +78,7 @@ private[sql] object JDBCRDD extends Logging { | |
| case java.sql.Types.NCHAR => StringType | ||
| case java.sql.Types.NCLOB => StringType | ||
| case java.sql.Types.NULL => null | ||
| case java.sql.Types.NUMERIC | ||
| if precision != 0 || scale != 0 => DecimalType.bounded(precision, scale) | ||
| case java.sql.Types.NUMERIC => DecimalType.SYSTEM_DEFAULT | ||
| case java.sql.Types.NUMERIC => DecimalType.bounded(precision, scale) | ||
| case java.sql.Types.NVARCHAR => StringType | ||
| case java.sql.Types.OTHER => null | ||
| case java.sql.Types.REAL => DoubleType | ||
|
|
||
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.
It's risky to change this one, I'd only change the JDBCRDD
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 will take your word for the risk involved, I am very new to this project.
From a layman's perspective, it seems that doing some basic checks when instantiating the type would make the type more robust. If I understand correctly a
precision <= 0is not allowed, so this patch returns a /default/ decimal. Similarly, ascale > precisionis not allowed, so it returns a decimal with the scale truncated to the size of the precision. My thoughts are that this will catch unexpected inputs and still behave in an expected way. Users instantiating these decimals in the ways that are intended will still get the same type back.