Created
April 29, 2016 21:57
-
-
Save rsds143/2a4c1225cb64a02d173342bfc2ba8c58 to your computer and use it in GitHub Desktop.
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
| /** | |
| * :: DeveloperApi :: | |
| * Default Oracle dialect, mapping a nonspecific numeric type to a general decimal type. | |
| */ | |
| @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 precision and -127 scale | |
| // For more details, please see | |
| // https://github.com/apache/spark/pull/8780#issuecomment-145598968 | |
| // and | |
| // https://github.com/apache/spark/pull/8780#issuecomment-144541760 | |
| 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. | |
| Some(DecimalType(38, 10)) | |
| } else { | |
| None | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment