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

    https://github.com/apache/spark/pull/10312#discussion_r47928977
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -303,7 +315,34 @@ final class DataFrameWriter private[sql](df: 
DataFrame) {
           conn.close()
         }
     
    -    JdbcUtils.saveTable(df, url, table, props)
    +    JdbcUtils.saveTable(df, url, table, props, columnMapping)
    +  }
    +
    +  /**
    +   * (java-friendly) version of
    +   * 
[[DataFrameWriter.jdbc(String,String,Properties,scala.collection.Map[String,String]):]]
    +   */
    +  def jdbc(url: String,
    +           table: String,
    +           connectionProperties: Properties,
    +           columnMapping: java.util.Map[String, String]): Unit = {
    +    // Convert java Map into scala Map
    +    var sColumnMapping: scala.collection.Map[String, String] = null
    +    if (columnMapping!=null) {
    +        sColumnMapping = columnMapping.asScala
    +    }
    +    jdbc(url, table, connectionProperties, sColumnMapping)
    +  }
    +
    +  /**
    +   * Three parameter version of
    +   * 
[[DataFrameWriter.jdbc(String,String,Properties,scala.collection.Map[String,String]):]]
    +   */
    +  def jdbc(url: String,
    +           table: String,
    +           connectionProperties: Properties): Unit = {
    +    val columnMapping: scala.collection.Map[String, String] = null
    +    jdbc(url, table, connectionProperties, columnMapping)
    --- End diff --
    
    Rather than declare a dummy var, I think you can pass 
`null.asInstanceOf[Map[String, String]]`? or an empty `Map`? I suppose that 
depends on what the semantics of an empty map should be.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to