Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/15975#discussion_r89693478 --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameReader.scala --- @@ -220,22 +228,14 @@ class DataFrameReader private[sql](sparkSession: SparkSession) extends Logging { table: String, predicates: Array[String], connectionProperties: Properties): DataFrame = { + // connectionProperties should override settings in extraOptions. + val params = extraOptions.toMap ++ connectionProperties.asScala.toMap + val options = new JDBCOptions(url, table, params) val parts: Array[Partition] = predicates.zipWithIndex.map { case (part, i) => JDBCPartition(part, i) : Partition } - jdbc(url, table, parts, connectionProperties) - } - - private def jdbc( - url: String, - table: String, - parts: Array[Partition], - connectionProperties: Properties): DataFrame = { - // connectionProperties should override settings in extraOptions. - this.extraOptions = this.extraOptions ++ connectionProperties.asScala - // explicit url and dbtable should override all - this.extraOptions += ("url" -> url, "dbtable" -> table) - format("jdbc").load() + val relation = JDBCRelation(parts, options)(sparkSession) + sparkSession.baseRelationToDataFrame(relation) --- End diff -- Yeah. The predicate-based API is very useful for the advanced JDBC users.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org