cloud-fan commented on a change in pull request #35727:
URL: https://github.com/apache/spark/pull/35727#discussion_r819556670



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
##########
@@ -99,6 +99,16 @@ abstract class JdbcDialect extends Serializable with Logging{
    */
   def getJDBCType(dt: DataType): Option[JdbcType] = None
 
+  /**
+   * Get the factory method for create JDBC connection.
+   * In general, creating a connection has nothing to do with JDBC partition.
+   * But sometimes it is needed, such as a database with multiple shard nodes.
+   * @param options JDBC options.
+   * @return The factory method for create JDBC connection.
+   */
+  def getConnection(options: JDBCOptions): JDBCPartition => Connection =
+    JDBCPartition => JdbcUtils.createConnectionFactory(options)()

Review comment:
       I'd like to see we remove `JdbcUtils.createConnectionFactory` and inline 
the code here. This makes sure that all the places will use `JdbcDialects` to 
get the connection.




-- 
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]

Reply via email to