GitHub user HyukjinKwon opened a pull request:

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

    [SPARK-19919][SQL] Defer throwing the exception for empty paths in CSV 
datasource into `DataSource`

    ## What changes were proposed in this pull request?
    
    This PR proposes to defer throwing the exception within `DataSource`.
    
    Currently, if other datasources fail to infer the schema, it returns `None` 
and then this is being validated in `DataSource` as below:
    
    ```
    scala> spark.read.json("emptydir")
    org.apache.spark.sql.AnalysisException: Unable to infer schema for JSON. It 
must be specified manually.;
    ```
    
    ```
    scala> spark.read.orc("emptydir")
    org.apache.spark.sql.AnalysisException: Unable to infer schema for ORC. It 
must be specified manually.;
    ```
    
    ```
    scala> spark.read.parquet("emptydir")
    org.apache.spark.sql.AnalysisException: Unable to infer schema for Parquet. 
It must be specified manually.;
    ```
    
    However, CSV it checks it within the datasource implementation and throws 
another exception message as below:
    
    ```
    scala> spark.read.csv("emptydir")
    java.lang.IllegalArgumentException: requirement failed: Cannot infer schema 
from an empty set of files
    ```
    
    We could remove this duplicated check and validate this in one place in the 
same way with the same message.
    
    ## How was this patch tested?
    
    Unit test in `CSVSuite` and manual test.


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

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

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

    https://github.com/apache/spark/pull/17256.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 #17256
    
----
commit 9d91da124e0723adee7744a64999ea1c07acfe66
Author: hyukjinkwon <gurwls...@gmail.com>
Date:   2017-03-11T06:53:39Z

    Defer input path validation into DataSource in CSV datasource

----


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