Skip to content

Commit

Permalink
[SPARK-11394][SQL] Throw IllegalArgumentException for unsupported typ…
Browse files Browse the repository at this point in the history
…es in postgresql

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

Author: Takeshi YAMAMURO <[email protected]>

Closes apache#9350 from maropu/FixBugInPostgreJdbc.
  • Loading branch information
maropu authored and yhuai committed Dec 29, 2015
1 parent 1a91be8 commit 73862a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down

0 comments on commit 73862a1

Please sign in to comment.