You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Justin Pihony (JIRA)" <ji...@apache.org> on 2016/04/13 08:22:25 UTC

[jira] [Issue Comment Deleted] (SPARK-14525) DataFrameWriter's save method should delegate to jdbc for jdbc datasource

     [ https://issues.apache.org/jira/browse/SPARK-14525?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Justin Pihony updated SPARK-14525:
----------------------------------
    Comment: was deleted

(was: I don't see why not since they're just key/values anyway. Here's the code I put together before realizing I didn't like the first option:

{code}
    dataSource.providingClass.newInstance() match {
      case x: org.apache.spark.sql.execution.datasources.jdbc.DefaultSource  => {
        val url = extraOptionsgetOrElse("url", 
                     sys.error("Saving jdbc source requires url to be set. (ie. df.option(\"url\", \"ACTUAL_URL\")"))
        val table = extraOptions.getOrElse("dbtable", extraOptions.getOrElse("table", 
                     sys.error("Saving jdbc source requires dbtable to be set. (ie. df.option(\"dbtable\", \"ACTUAL_DB_TABLE\")")))
        //Rely on the impl of jdbc? which puts the user and password into the properties from extraOptions anyway?
        jdbc(url, table, new java.util.Properties)
      }
      case _ => dataSource.write(mode, df)
    }
{code})

> DataFrameWriter's save method should delegate to jdbc for jdbc datasource
> -------------------------------------------------------------------------
>
>                 Key: SPARK-14525
>                 URL: https://issues.apache.org/jira/browse/SPARK-14525
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 1.6.1
>            Reporter: Justin Pihony
>            Priority: Minor
>
> If you call {code}df.write.format("jdbc")...save(){code} then you get an error  
> bq. org.apache.spark.sql.execution.datasources.jdbc.DefaultSource does not allow create table as select
> save is a more intuitive guess on the appropriate method to call, so the user should not be punished for not knowing about the jdbc method. 
> Obviously, this will require the caller to have set up the correct parameters for jdbc to work :)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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