Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18266#discussion_r138475068
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRelation.scala
 ---
    @@ -111,7 +111,16 @@ private[sql] case class JDBCRelation(
     
       override val needConversion: Boolean = false
     
    -  override val schema: StructType = JDBCRDD.resolveTable(jdbcOptions)
    +  override val schema: StructType = {
    +    val schema = JDBCRDD.resolveTable(jdbcOptions)
    +    val customSchema = jdbcOptions.customSchema
    +    if (customSchema.isDefined) {
    +      JdbcUtils.parseUserSpecifiedColumnTypes(schema, customSchema.get,
    +        sqlContext.sessionState.conf.resolver)
    +    } else {
    +      schema
    +    }
    --- End diff --
    
    ```Scala
        val tableSchema = JDBCRDD.resolveTable(jdbcOptions)
        jdbcOptions.customSchema match {
          case Some(customSchema) => JdbcUtils.parseUserSpecifiedColumnTypes(
            tableSchema, customSchema, sparkSession.sessionState.conf.resolver)
          case None => tableSchema
        }
    ```


---

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

Reply via email to