You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GraceH <gi...@git.apache.org> on 2016/08/09 07:57:23 UTC

[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

GitHub user GraceH opened a pull request:

    https://github.com/apache/spark/pull/14559

    [SPARK-16968]Add additional options in jdbc when creating a new table

    ## What changes were proposed in this pull request?
    
    In the PR, we just allow the user to add additional options when create a new table in JDBC writer. 
    The options can be table_options or partition_options.
    E.g., "CREATE TABLE t (name string) ENGINE=InnoDB DEFAULT CHARSET=utf8"
    
    ## How was this patch tested?
    
    (Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
    will apply test result soon.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/GraceH/spark jdbc_options

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/14559.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #14559
    
----
commit b302b1c7ec75ae1e78d132f7ecdb9bb7f33816d4
Author: GraceH <93...@qq.com>
Date:   2016-08-09T06:47:51Z

    Add additional options in jdbc when creating a new table

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63436 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63436/consoleFull)** for PR 14559 at commit [`6a3cb42`](https://github.com/apache/spark/commit/6a3cb4226027e7d22b7606c0e890d258eb8da138).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63666 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63666/consoleFull)** for PR 14559 at commit [`d0bdd35`](https://github.com/apache/spark/commit/d0bdd35acfe8181612efdb22ac96280af70b354e).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74015718
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    +            case Some(value) => " " + value
    +            case None => ""
    +          }
    +        }
    +        val sql = s"CREATE TABLE $table ($schema)" + createtblOptions
    --- End diff --
    
    Why not also use interpolation for the new var?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    This is looking good. I'm not as familiar with the Python API but it doesn't seem like this needs a change in an API anywhere, Scala or Python. So I think this is OK.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74027679
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    --- End diff --
    
    Ah I think that's better, yeah. This is indeed just an option to the method call.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63587 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63587/consoleFull)** for PR 14559 at commit [`57be055`](https://github.com/apache/spark/commit/57be055c542d1720bb9fd57810d4c26666593444).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63436/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63587/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63427 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63427/consoleFull)** for PR 14559 at commit [`b302b1c`](https://github.com/apache/spark/commit/b302b1c7ec75ae1e78d132f7ecdb9bb7f33816d4).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74028584
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    +            case Some(value) => " " + value
    +            case None => ""
    +          }
    +        }
    +        val sql = s"CREATE TABLE $table ($schema)" + createtblOptions
    --- End diff --
    
    To have a better format(to tell two parts explicitly), how about this?
    ```
    val createtblOptions = extraOptions.getOrElse("createTableOptions", "")
    val sql = s"CREATE TABLE $table ($schema) $createtblOptions"
    ```
    The only problem here is to introduce a redundant space if option is empty. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63667 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63667/consoleFull)** for PR 14559 at commit [`21b4278`](https://github.com/apache/spark/commit/21b4278c2e6d46510645464ac083d83108693133).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class JDBCOptions(`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74278231
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    @HyukjinKwon  For those database specific options can be merged as createTableOptions. Not recommend to enumerate them one by one. Just as @srowen suggested.
    
    Thanks to @HyukjinKwon and @srowen. I will propose a draft, and back to both of you later. Thanks. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74015696
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    --- End diff --
    
    Probably need a different prop name starting with spark. See other option naming conventions. The outer scope isn't necessary.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74177938
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    I am just wondering if it is possible to put the option in `JDBCOptions` (maybe with `truncate` as well). Also, I guess i'd be better if this option is documented in both `DataFrameWriter` and `readwriter.py`. For example `truncate` is documented above. 
    
    In addition, I just found the documentation for `truncate` is missed in `readwriter.py`. It might be nicer if this one is fixed together here.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63427 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63427/consoleFull)** for PR 14559 at commit [`b302b1c`](https://github.com/apache/spark/commit/b302b1c7ec75ae1e78d132f7ecdb9bb7f33816d4).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63664/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63437/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63662/
    Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74550111
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -423,6 +423,10 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
         props.putAll(connectionProperties)
         val conn = JdbcUtils.createConnectionFactory(url, props)()
     
    +    // to add required options like URL and dbtable
    +    val params = extraOptions.toMap ++ Map("url" -> url, "dbtable" -> table)
    +    val jdbcOptions = new JDBCOptions(params)
    +
         try {
           var tableExists = JdbcUtils.tableExists(conn, url, table)
    --- End diff --
    
    BTW\uff0c there are several places of (url and table). shall we replace all of them?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test FAILed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63667/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74188842
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    A quick question here. The JDBCOptions also contain URL and table information, like:
    ```
     // a JDBC URL
      val url = parameters.getOrElse("url", sys.error("Option 'url' not specified"))
      // name of table
      val table = parameters.getOrElse("dbtable", sys.error("Option 'dbtable' not specified"))
    ```
    Shall we merge those information into current DataFrameWriter as well?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74542387
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCWriteSuite.scala ---
    @@ -174,6 +174,18 @@ class JDBCWriteSuite extends SharedSQLContext with BeforeAndAfter {
         JdbcDialects.unregisterDialect(testH2Dialect)
       }
     
    +  test("createTableOptions") {
    +    JdbcDialects.registerDialect(testH2Dialect)
    +    val df = spark.createDataFrame(sparkContext.parallelize(arr2x2), schema2)
    +
    +    val m = intercept[org.h2.jdbc.JdbcSQLException] {
    +      df.write.option("createTableOptions", "ENGINE tableEngineName")
    +      .jdbc(url1, "TEST.CREATETBLOPTS", properties)
    +      }.getMessage
    --- End diff --
    
    Maybe the indentation can be as below (it seems there are extra double spaces now):
    
    ```scala
    val m = intercept[org.h2.jdbc.JdbcSQLException] {
      ...
    }.getMessage
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74028772
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    +            case Some(value) => " " + value
    +            case None => ""
    +          }
    +        }
    +        val sql = s"CREATE TABLE $table ($schema)" + createtblOptions
    --- End diff --
    
    You could `map` and then `getOrElse` to add the space. The space isn't a big deal anyway. I think it's tidier this way, though originally I was just suggesting not mixing concatenation and interpolation in one line.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63662 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63662/consoleFull)** for PR 14559 at commit [`4fb5e55`](https://github.com/apache/spark/commit/4fb5e55a50531abf255169c275ad2ad2cf2d71f2).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    +1 for both OK and not exposing `JDBCOptions`. I know it is slightly different but `CSVoptions` and `JSONOptions` would be good references to follow.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Hi @srowen @rxin , sorry for late response. I have added the document part. https://github.com/GraceH/spark/commit/8360c2911b70aa628f8edba593e3764d3b07ca55
    Shall I raise a new PR?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63666 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63666/consoleFull)** for PR 14559 at commit [`d0bdd35`](https://github.com/apache/spark/commit/d0bdd35acfe8181612efdb22ac96280af70b354e).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63437 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63437/consoleFull)** for PR 14559 at commit [`eb0656b`](https://github.com/apache/spark/commit/eb0656b1b0723e7e7d2fe9f3f9b0ca339772076f).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    @GraceH yeah you'll need a new PR. You can open it vs the same JIRA since these are fairly tightly related.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Are the options here documented anywhere?



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63664 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63664/consoleFull)** for PR 14559 at commit [`186a582`](https://github.com/apache/spark/commit/186a5828fddfdd9c6e2d778ff28b30d3b1d2c471).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63667 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63667/consoleFull)** for PR 14559 at commit [`21b4278`](https://github.com/apache/spark/commit/21b4278c2e6d46510645464ac083d83108693133).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74207701
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    Oh good point about JDBCOptions. I wouldn't mind fixing truncate while we're here, yeah, although it's a slightly different issue.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged to master


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63675 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63675/consoleFull)** for PR 14559 at commit [`5176fdb`](https://github.com/apache/spark/commit/5176fdb90e6ea0bc2b7cc4e1e5d36811d8403b93).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74192910
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    (BTW, I am not used to the options such as `ENGINE=InnoDB DEFAULT CHARSET=utf8`. Maybe we can just wait for the better feedback.)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    @HyukjinKwon and @srowen, here is the initial proposal. Please let me know your comment. I will refine that with unit test later.
    
    BTW, the readwriter.py calls high level api of jdbc(url, table, connectionProperties). If we don't change that API like reader api does, we may not need to expose the JDBCOptions in that file. What do you think? 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74192492
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    I think it'd make sense if those options are documented too because I am sure all the options should be documented rather than only some.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63436 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63436/consoleFull)** for PR 14559 at commit [`6a3cb42`](https://github.com/apache/spark/commit/6a3cb4226027e7d22b7606c0e890d258eb8da138).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63437 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63437/consoleFull)** for PR 14559 at commit [`eb0656b`](https://github.com/apache/spark/commit/eb0656b1b0723e7e7d2fe9f3f9b0ca339772076f).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74542181
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala ---
    @@ -20,14 +20,21 @@ package org.apache.spark.sql.execution.datasources.jdbc
     /**
      * Options for the JDBC data source.
      */
    -private[jdbc] class JDBCOptions(
    +private[sql] class JDBCOptions(
    --- End diff --
    
    Actually, if my understanding is correct, we don't need `private[sql]` here. (See  https://github.com/apache/spark/commit/511f52f8423e151b0d0133baf040d34a0af3d422)



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63666/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63587 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63587/consoleFull)** for PR 14559 at commit [`57be055`](https://github.com/apache/spark/commit/57be055c542d1720bb9fd57810d4c26666593444).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74546716
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -423,6 +423,10 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
         props.putAll(connectionProperties)
         val conn = JdbcUtils.createConnectionFactory(url, props)()
     
    +    // to add required options like URL and dbtable
    +    val params = extraOptions.toMap ++ Map("url" -> url, "dbtable" -> table)
    +    val jdbcOptions = new JDBCOptions(params)
    +
         try {
           var tableExists = JdbcUtils.tableExists(conn, url, table)
    --- End diff --
    
    Sure. make sense.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    sure. Both are ok to me. will document those options. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74542628
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala ---
    @@ -20,14 +20,21 @@ package org.apache.spark.sql.execution.datasources.jdbc
     /**
      * Options for the JDBC data source.
      */
    -private[jdbc] class JDBCOptions(
    +private[sql] class JDBCOptions(
    --- End diff --
    
    OK. Just intend to follow that origin style. I will fix that. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74027475
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    --- End diff --
    
    Thanks Sean. Actually, here I have a little bit hesitation. For example, "mergeSchema" which may not be so that similar to the other option name (prefixed with "spark"). 
    ```
    val mergedDF = spark.read.option("mergeSchema", "true").parquet("data/test_table")
    ```
    
    How about to use some short name as "createTableOptions"?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74187289
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    OK. Let me take a look. and give a quick version.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74207520
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    These options are all database-specific, so we can give an example like this but not document all of them.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63675 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63675/consoleFull)** for PR 14559 at commit [`5176fdb`](https://github.com/apache/spark/commit/5176fdb90e6ea0bc2b7cc4e1e5d36811d8403b93).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63427/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63664 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63664/consoleFull)** for PR 14559 at commit [`186a582`](https://github.com/apache/spark/commit/186a5828fddfdd9c6e2d778ff28b30d3b1d2c471).


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74026903
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    +            case Some(value) => " " + value
    +            case None => ""
    +          }
    +        }
    +        val sql = s"CREATE TABLE $table ($schema)" + createtblOptions
    --- End diff --
    
    Yes. so right. will fix that, which looks better as a whole part. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Merged build finished. Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74546013
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -423,6 +423,10 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
         props.putAll(connectionProperties)
         val conn = JdbcUtils.createConnectionFactory(url, props)()
     
    +    // to add required options like URL and dbtable
    +    val params = extraOptions.toMap ++ Map("url" -> url, "dbtable" -> table)
    +    val jdbcOptions = new JDBCOptions(params)
    +
         try {
           var tableExists = JdbcUtils.tableExists(conn, url, table)
    --- End diff --
    
    Maybe I think we can use `jsonOptions.url` and `jsonOptions.table` here. I know there are no differences but as we made the `JDBCOptions` object to tie up the extra options.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    **[Test build #63662 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/63662/consoleFull)** for PR 14559 at commit [`4fb5e55`](https://github.com/apache/spark/commit/4fb5e55a50531abf255169c275ad2ad2cf2d71f2).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    This is a pretty general issue for JDBC users. Could we backport it to Spark 2.0? 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Oh... good point. I see the existing `truncate` option isn't documented either. Yes that should be done in `sql-programming-guide.md`. We can follow up on this one or make a new small issue for it.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74029250
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,16 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = {
    +          extraOptions.get("jdbc.create.table.options") match {
    +            case Some(value) => " " + value
    +            case None => ""
    +          }
    +        }
    +        val sql = s"CREATE TABLE $table ($schema)" + createtblOptions
    --- End diff --
    
    Totally got your idea. Thanks a lot for the prompt response. I will update the patch. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by GraceH <gi...@git.apache.org>.
Github user GraceH commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Thanks all. I have added the unit test in JDBCWriterSuite. Any further comment, please feel free to let me know. 
    
    BTW, or we can point the user to check JDBCOptions for further configuration information.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74550467
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -423,6 +423,10 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
         props.putAll(connectionProperties)
         val conn = JdbcUtils.createConnectionFactory(url, props)()
     
    +    // to add required options like URL and dbtable
    +    val params = extraOptions.toMap ++ Map("url" -> url, "dbtable" -> table)
    +    val jdbcOptions = new JDBCOptions(params)
    +
         try {
           var tableExists = JdbcUtils.tableExists(conn, url, table)
    --- End diff --
    
    Yes, I think we can.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #14559: [SPARK-16968]Add additional options in jdbc when creatin...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/14559
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/63675/
    Test PASSed.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/14559


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #14559: [SPARK-16968]Add additional options in jdbc when ...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14559#discussion_r74178124
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
    @@ -447,7 +447,11 @@ final class DataFrameWriter[T] private[sql](ds: Dataset[T]) {
           // Create the table if the table didn't exist.
           if (!tableExists) {
             val schema = JdbcUtils.schemaString(df, url)
    -        val sql = s"CREATE TABLE $table ($schema)"
    +        // 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 = extraOptions.getOrElse("createTableOptions", "")
    --- End diff --
    
    One more thing is, I guess we might need a test in `JDBCWriteSuite`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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