Skip to content

Commit

Permalink
[SPARK-14204][SQL] register driverClass rather than user-specified class
Browse files Browse the repository at this point in the history
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 <[email protected]>

Closes #14420 from mchalek/mchalek-jdbc_driver_registration.

(cherry picked from commit 685b08e)
Signed-off-by: Sean Owen <[email protected]>
  • Loading branch information
mchalek authored and srowen committed Aug 3, 2016
1 parent 2daab33 commit b44da5b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ object JdbcUtils extends Logging {
DriverManager.getDriver(url).getClass.getCanonicalName
}
() => {
userSpecifiedDriverClass.foreach(DriverRegistry.register)
DriverRegistry.register(driverClass)
val driver: Driver = DriverManager.getDrivers.asScala.collectFirst {
case d: DriverWrapper if d.wrapped.getClass.getCanonicalName == driverClass => d
case d if d.getClass.getCanonicalName == driverClass => d
Expand Down

0 comments on commit b44da5b

Please sign in to comment.