GitHub user HyukjinKwon opened a pull request:

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

    Make jdbc() and read.format("jdbc") consistently throwing exception for 
user-specified schema

    ## What changes were proposed in this pull request?
    
    Currently,
    
    ```scala
    spark.read.schema(StructType(Seq())).jdbc(...),show()
    ```
    
    does not throws an exception whereas
    
    ```scala
    
spark.read.schema(StructType(Seq())).option(...).format("jdbc").load().show()
    ```
    
    does as below:
    
    ```
    jdbc does not allow user-specified schemas.;
    org.apache.spark.sql.AnalysisException: jdbc does not allow user-specified 
schemas.;
        at 
org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:320)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:149)
        at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:122)
        at 
org.apache.spark.sql.jdbc.JDBCSuite$$anonfun$17.apply$mcV$sp(JDBCSuite.scala:351)
    ```
    
    It'd make sense throwing the exception when user specifies schema 
identically.
    
    This PR makes the behaviour consistent for both jdbc APIs.
    
    ## How was this patch tested?
    
    Unit test in `JDBCSuite`.

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

    $ git pull https://github.com/HyukjinKwon/spark SPARK-16848

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

    https://github.com/apache/spark/pull/14451.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 #14451
    
----
commit 3def251fb9bd213e0d343cd404f9896a576c0d74
Author: hyukjinkwon <gurwls...@gmail.com>
Date:   2016-08-02T05:07:57Z

    Make jdbc() and read.format("jdbc") consistently throwing exception for 
user-specified schema

----


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

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

Reply via email to