Skip to content

Commit b44da5b

Browse files
mchaleksrowen
authored andcommitted
[SPARK-14204][SQL] register driverClass rather than user-specified class
This is a pull request that was originally merged against branch-1.6 as #12000, now being merged into master as well. srowen zzcclp JoshRosen This pull request fixes an issue in which cluster-mode executors fail to properly register a JDBC driver when the driver is provided in a jar by the user, but the driver class name is derived from a JDBC URL (rather than specified by the user). The consequence of this is that all JDBC accesses under the described circumstances fail with an IllegalStateException. I reported the issue here: https://issues.apache.org/jira/browse/SPARK-14204 My proposed solution is to have the executors register the JDBC driver class under all circumstances, not only when the driver is specified by the user. This patch was tested manually. I built an assembly jar, deployed it to a cluster, and confirmed that the problem was fixed. Author: Kevin McHale <kevin@premise.com> Closes #14420 from mchalek/mchalek-jdbc_driver_registration. (cherry picked from commit 685b08e) Signed-off-by: Sean Owen <sowen@cloudera.com>
1 parent 2daab33 commit b44da5b

File tree

1 file changed

+1
-1
lines changed
  • sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc

1 file changed

+1
-1
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object JdbcUtils extends Logging {
5454
DriverManager.getDriver(url).getClass.getCanonicalName
5555
}
5656
() => {
57-
userSpecifiedDriverClass.foreach(DriverRegistry.register)
57+
DriverRegistry.register(driverClass)
5858
val driver: Driver = DriverManager.getDrivers.asScala.collectFirst {
5959
case d: DriverWrapper if d.wrapped.getClass.getCanonicalName == driverClass => d
6060
case d if d.getClass.getCanonicalName == driverClass => d

0 commit comments

Comments
 (0)