GitHub user HyukjinKwon opened a pull request:

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

    [SPARK-20590][SQL] Use Spark internal datasource if multiples are found for 
the same shorten name

    ## What changes were proposed in this pull request?
    
    This PR proposes a different approach for 
https://github.com/apache/spark/pull/17847
    
    ## How was this patch tested?
    
    Manually tested as below:
    
    ```bash
    ./bin/spark-shell --packages com.databricks:spark-csv_2.11:1.5.0
    ```
    
    ```scala
    spark.sparkContext.setLogLevel("WARN")
    ```
    
    **positive cases**:
    
    ```bash
    scala> spark.range(1).write.format("csv").mode("overwrite").save("/tmp/abc")
    17/05/09 16:32:56 WARN DataSource: Multiple sources found for csv 
(org.apache.spark.sql.execution.datasources.csv.CSVFileFormat, 
     com.databricks.spark.csv.DefaultSource15), please specify the fully 
qualified class name.
     Using the internal datasource 
(org.apache.spark.sql.execution.datasources.csv.CSVFileFormat).
    ```
    
    (newlines were inserted for readability).
    
    ```scala
    scala> 
spark.range(1).write.format("com.databricks.spark.csv").mode("overwrite").save("/tmp/abc")
    ```
    
    ```scala
    scala> 
spark.range(1).write.format("org.apache.spark.sql.execution.datasources.csv.CSVFileFormat").mode("overwrite").save("/tmp/abc")
    ```
    
    ```scala
    scala> spark.range(1).write.format("Csv").save("/tmp/abc1")
    ```
    
    **negative cases**:
    
    ```scala
    scala> 
spark.range(1).write.format("com.databricks.spark.csv.CsvRelation").save("/tmp/abc")
    java.lang.InstantiationException: com.databricks.spark.csv.CsvRelation
    ...
    ```
    
    ```scala
    scala> 
spark.range(1).write.format("com.databricks.spark.csv.CsvRelatio").save("/tmp/abc")
    java.lang.ClassNotFoundException: Failed to find data source: 
com.databricks.spark.csv.CsvRelatio. Please find packages at 
http://spark.apache.org/third-party-projects.html
    ...
    ```


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

    $ git pull https://github.com/HyukjinKwon/spark datasource-detect

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

    https://github.com/apache/spark/pull/17916.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 #17916
    
----

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to