johnnywalker commented on code in PR #45410:
URL: https://github.com/apache/spark/pull/45410#discussion_r1520132359


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala:
##########
@@ -153,12 +153,12 @@ object JDBCRDD extends Logging {
  */
 class JDBCRDD(

Review Comment:
   Thanks @utkarshwealthy for the proposal. Would something like this be 
acceptable instead?
   
   ```scala
   diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
   index 7eff4bd376b..024e7327de7 100644
   --- 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
   +++ 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
   @@ -142,6 +142,7 @@ object JDBCRDD extends Logging {
          limit,
          sortOrders,
          offset)
   +      .withDialect(dialect)
      }
      // scalastyle:on argcount
    }
   @@ -174,7 +175,21 @@ class JDBCRDD(
        sparkContext,
        name = "JDBC query execution time")
    
   -  private lazy val dialect = JdbcDialects.get(url)
   +  /**
   +   * Dialect to use instead of inferring it from the URL.
   +   */
   +  private var prescribedDialect: Option[JdbcDialect] = None
   +
   +  private lazy val dialect = 
prescribedDialect.getOrElse(JdbcDialects.get(url))
   +
   +  /**
   +   * Prescribe a particular dialect to use for this RDD. If not set, the 
dialect will be automatically
   +   * resolved from the JDBC URL. This previous behavior is preserved for 
binary compatibility.
   +   */
   +  def withDialect(dialect: JdbcDialect): JDBCRDD = {
   +    prescribedDialect = Some(dialect)
   +    this
   +  }
    
      def generateJdbcQuery(partition: Option[JDBCPartition]): String = {
        // H2's JDBC driver does not support the setSchema() method.  We pass a
   ```



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to