beliefer commented on a change in pull request #35696:
URL: https://github.com/apache/spark/pull/35696#discussion_r817402419
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
##########
@@ -60,9 +60,9 @@ object JdbcUtils extends Logging with SQLConfHelper {
* @param options - JDBC options that contains url, table and other
information.
* @throws IllegalArgumentException if the driver could not open a JDBC
connection.
*/
- def createConnectionFactory(options: JDBCOptions): () => Connection = {
+ def createConnectionFactory(options: JDBCOptions): Option[Partition] =>
Connection = {
Review comment:
We get the jdbc connection looks like:
```
private def createConnectionFactoryByShard(options: JDBCOptions): Partition
=> Connection = {
val shards = ShardOptions.create(options)
val driverClass: String = options.driverClass
(thePart: Partition) => {
require(thePart.index < shards.shards.length)
val url = shards.shards.apply(thePart.index)
logInfo(s"Create connection for shard: $url")
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
}.getOrElse {
throw new IllegalStateException(
s"Did not find registered driver with class $driverClass")
}
driver.connect(url, options.asConnectionProperties)
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]