-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-10648] Oracle dialect to handle nonspecific numeric types #9495
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
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 |
|---|---|---|
|
|
@@ -139,6 +139,7 @@ object JdbcDialects { | |
| registerDialect(DB2Dialect) | ||
| registerDialect(MsSqlServerDialect) | ||
| registerDialect(DerbyDialect) | ||
| registerDialect(OracleDialect) | ||
|
|
||
|
|
||
| /** | ||
|
|
@@ -315,3 +316,27 @@ case object DerbyDialect extends JdbcDialect { | |
|
|
||
| } | ||
|
|
||
| /** | ||
| * :: DeveloperApi :: | ||
| * Default Oracle dialect, mapping a nonspecific | ||
| * numeric type to a general decimal type. | ||
| * Solution by @cloud-fan and @bdolbeare (github.com) | ||
| */ | ||
| @DeveloperApi | ||
| case object OracleDialect extends JdbcDialect { | ||
| override def canHandle(url: String): Boolean = url.startsWith("jdbc:oracle") | ||
| override def getCatalystType( | ||
| sqlType: Int, typeName: String, size: Int, md: MetadataBuilder): Option[DataType] = { | ||
| // Handle NUMBER fields that have no precision/scale in special way | ||
| // because JDBC ResultSetMetaData converts this to 0 procision and -127 scale | ||
| if (sqlType == Types.NUMERIC && size == 0) { | ||
| // This is sub-optimal as we have to pick a precision/scale in advance whereas the data | ||
| // in Oracle is allowed to have different precision/scale for each value. | ||
| // This conversion works in our domain for now though we need a more durable solution. | ||
| // Look into changing JDBCRDD (line 406): | ||
|
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. I think putting the line number at here is not a very robust way. Since we already described the problem, we can simply explain our workaround at here. |
||
| // FROM: mutableRow.update(i, Decimal(decimalVal, p, s)) | ||
| // TO: mutableRow.update(i, Decimal(decimalVal)) | ||
| Some(DecimalType(DecimalType.MAX_PRECISION, 10)) | ||
| } else None | ||
|
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. |
||
| } | ||
| } | ||
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.
@travishegner To provide more information, you can provide the links to their comments.