spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yh...@apache.org
Subject spark git commit: [SPARK-11394][SQL] Throw IllegalArgumentException for unsupported types in postgresql
Date Tue, 29 Dec 2015 05:28:36 GMT
Repository: spark
Updated Branches:
  refs/heads/master 1a91be807 -> 73862a1eb


[SPARK-11394][SQL] Throw IllegalArgumentException for unsupported types in postgresql

If DataFrame has BYTE types, throws an exception:
org.postgresql.util.PSQLException: ERROR: type "byte" does not exist

Author: Takeshi YAMAMURO <linguin.m.s@gmail.com>

Closes #9350 from maropu/FixBugInPostgreJdbc.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/73862a1e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/73862a1e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/73862a1e

Branch: refs/heads/master
Commit: 73862a1eb9744c3c32458c9c6f6431c23783786a
Parents: 1a91be8
Author: Takeshi YAMAMURO <linguin.m.s@gmail.com>
Authored: Mon Dec 28 21:28:32 2015 -0800
Committer: Yin Huai <yhuai@databricks.com>
Committed: Mon Dec 28 21:28:32 2015 -0800

----------------------------------------------------------------------
 .../main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala   | 1 +
 .../src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala     | 4 ++++
 2 files changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/73862a1e/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala
----------------------------------------------------------------------
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala
index 3cf80f5..ad9e316 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/PostgresDialect.scala
@@ -64,6 +64,7 @@ private object PostgresDialect extends JdbcDialect {
       getJDBCType(et).map(_.databaseTypeDefinition)
         .orElse(JdbcUtils.getCommonJDBCType(et).map(_.databaseTypeDefinition))
         .map(typeName => JdbcType(s"$typeName[]", java.sql.Types.ARRAY))
+    case ByteType => throw new IllegalArgumentException(s"Unsupported type in postgresql:
$dt");
     case _ => None
   }
 

http://git-wip-us.apache.org/repos/asf/spark/blob/73862a1e/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 7975c5d..4044a10 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
@@ -482,6 +482,10 @@ class JDBCSuite extends SparkFunSuite
     val Postgres = JdbcDialects.get("jdbc:postgresql://127.0.0.1/db")
     assert(Postgres.getCatalystType(java.sql.Types.OTHER, "json", 1, null) === Some(StringType))
     assert(Postgres.getCatalystType(java.sql.Types.OTHER, "jsonb", 1, null) === Some(StringType))
+    val errMsg = intercept[IllegalArgumentException] {
+      Postgres.getJDBCType(ByteType)
+    }
+    assert(errMsg.getMessage contains "Unsupported type in postgresql: ByteType")
   }
 
   test("DerbyDialect jdbc type mapping") {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message