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

    https://github.com/apache/spark/pull/12601#discussion_r80353253
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -420,62 +420,11 @@ final class DataFrameWriter[T] private[sql](ds: 
Dataset[T]) {
       def jdbc(url: String, table: String, connectionProperties: Properties): 
Unit = {
         assertNotPartitioned("jdbc")
         assertNotBucketed("jdbc")
    -
    -    // to add required options like URL and dbtable
    -    val params = extraOptions.toMap ++ Map("url" -> url, "dbtable" -> 
table)
    -    val jdbcOptions = new JDBCOptions(params)
    -    val jdbcUrl = jdbcOptions.url
    -    val jdbcTable = jdbcOptions.table
    -
    -    val props = new Properties()
    -    extraOptions.foreach { case (key, value) =>
    -      props.put(key, value)
    -    }
         // connectionProperties should override settings in extraOptions
    -    props.putAll(connectionProperties)
    -    val conn = JdbcUtils.createConnectionFactory(jdbcUrl, props)()
    -
    -    try {
    -      var tableExists = JdbcUtils.tableExists(conn, jdbcUrl, jdbcTable)
    -
    -      if (mode == SaveMode.Ignore && tableExists) {
    -        return
    -      }
    -
    -      if (mode == SaveMode.ErrorIfExists && tableExists) {
    -        sys.error(s"Table $jdbcTable already exists.")
    -      }
    -
    -      if (mode == SaveMode.Overwrite && tableExists) {
    -        if (jdbcOptions.isTruncate &&
    -            JdbcUtils.isCascadingTruncateTable(jdbcUrl) == Some(false)) {
    -          JdbcUtils.truncateTable(conn, jdbcTable)
    -        } else {
    -          JdbcUtils.dropTable(conn, jdbcTable)
    -          tableExists = false
    -        }
    -      }
    -
    -      // Create the table if the table didn't exist.
    -      if (!tableExists) {
    -        val schema = JdbcUtils.schemaString(df, jdbcUrl)
    -        // To allow certain options to append when create a new table, 
which can be
    -        // table_options or partition_options.
    -        // E.g., "CREATE TABLE t (name string) ENGINE=InnoDB DEFAULT 
CHARSET=utf8"
    -        val createtblOptions = jdbcOptions.createTableOptions
    -        val sql = s"CREATE TABLE $jdbcTable ($schema) $createtblOptions"
    -        val statement = conn.createStatement
    -        try {
    -          statement.executeUpdate(sql)
    -        } finally {
    -          statement.close()
    -        }
    -      }
    -    } finally {
    -      conn.close()
    -    }
    -
    -    JdbcUtils.saveTable(df, jdbcUrl, jdbcTable, props)
    +    this.extraOptions = this.extraOptions ++ (connectionProperties.asScala)
    +    // explicit url and dbtable should override all
    +    this.extraOptions += ("url" -> url, "dbtable" -> table)
    +    format("jdbc").save
    --- End diff --
    
    The omission of parentheses on methods should only be used when the method 
has no side-effects. 
    
    Thus, please change it to `save()`


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