You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by yh...@apache.org on 2016/02/29 21:38:34 UTC
spark git commit: [SPARK-12941][SQL][BRANCH-1.4] Spark-SQL JDBC
Oracle dialect fails to map string datatypes to Oracle VARCHAR datatype
Repository: spark
Updated Branches:
refs/heads/branch-1.4 a9b1b8025 -> 9d8404bf8
[SPARK-12941][SQL][BRANCH-1.4] Spark-SQL JDBC Oracle dialect fails to map string datatypes to Oracle VARCHAR datatype
Adding a getJDBCType() method to the JdbcDialects.scala which would create a VARCHAR type for Oracle create table operations.Currently the type TEXT is throwing exceptions which is incompatible to Oracle
Author: thomastechs <th...@tcs.com>
Closes #10912 from thomastechs/thomastechs-12941-branch.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/9d8404bf
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/9d8404bf
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/9d8404bf
Branch: refs/heads/branch-1.4
Commit: 9d8404bf8a09348f57c4479e2b39c174dc2867d6
Parents: a9b1b80
Author: thomastechs <th...@tcs.com>
Authored: Mon Feb 29 12:38:30 2016 -0800
Committer: Yin Huai <yh...@databricks.com>
Committed: Mon Feb 29 12:38:30 2016 -0800
----------------------------------------------------------------------
.../src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala | 5 +++++
.../src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala | 5 +++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/9d8404bf/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
index 8ae87d8..1901343 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
@@ -247,4 +247,9 @@ case object OracleDialect extends JdbcDialect {
None
}
}
+
+ override def getJDBCType(dt: DataType): Option[JdbcType] = dt match {
+ case StringType => Some(JdbcType("VARCHAR2(255)", java.sql.Types.VARCHAR))
+ case _ => None
+ }
}
http://git-wip-us.apache.org/repos/asf/spark/blob/9d8404bf/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
index de13633..f36cea0 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala
@@ -445,4 +445,9 @@ class JDBCSuite extends SparkFunSuite with BeforeAndAfter {
assert(agg.getCatalystType(1, "", 1, null) == Some(StringType))
}
+ test("OracleDialect type mapping") {
+ val oracleDialect = JdbcDialects.get("jdbc:oracle://127.0.0.1/db")
+ assert(oracleDialect.getJDBCType(StringType).
+ map(_.databaseTypeDefinition).get == "VARCHAR2(255)")
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org