You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/01/23 09:13:33 UTC

[GitHub] spark pull request #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver...

GitHub user gatorsmile opened a pull request:

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

    [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on the first try 

    ### What changes were proposed in this pull request?
    This PR is to revert some changes made in https://github.com/apache/spark/pull/15292
    
    > @darabos  reported Spark 2.1.0 issued the `No suitable driver` exception at the first time when reading a JDBC data source but simply re-executing the same command a second time "fixes" the `No suitable driver` error. This only happens when the Hive support is enabled. 
    
    Based on my understanding, the problem is `java.sql.DriverManager` class that can't access drivers loaded by Spark ClassLoader. The changes made in this PR does not sounds a solution for the reported issue. It could be caused by the other code changes in 2.1 that change the current ClassLoader 
    
    @darabos Could you please help us try it in your local environment? Thanks!
    
    ```
    $ ~/spark-2.1.0/bin/spark-shell --jars org.xerial.sqlite-jdbc-3.8.11.2.jar --driver-class-path org.xerial.sqlite-jdbc-3.8.11.2.jar
    [...]
    scala> spark.read.format("jdbc").option("url", "jdbc:sqlite:").option("dbtable", "x").load
    java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getDriver(DriverManager.java:315)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$7.apply(JDBCOptions.scala:84)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions$$anonfun$7.apply(JDBCOptions.scala:84)
      at scala.Option.getOrElse(Option.scala:121)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.<init>(JDBCOptions.scala:83)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions.<init>(JDBCOptions.scala:34)
      at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:32)
      at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:330)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:152)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:125)
      ... 48 elided
    
    scala> spark.read.format("jdbc").option("url", "jdbc:sqlite:").option("dbtable", "x").load
    java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: x)
    ```
    
    ### How was this patch tested?
    @darabos Could you make a manual test and see whether this changes can resolve your issue?

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

    $ git pull https://github.com/gatorsmile/spark jdbcDriver

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

    https://github.com/apache/spark/pull/16678.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 #16678
    
----
commit 9f5b11ba8c30a6908186ba392c090e4e9439d21d
Author: gatorsmile <ga...@gmail.com>
Date:   2017-01-23T09:01:06Z

    try1

----


---
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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver...

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

    https://github.com/apache/spark/pull/16678#discussion_r97290842
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala ---
    @@ -73,17 +73,7 @@ class JDBCOptions(
       // ------------------------------------------------------------
       // Optional parameters
       // ------------------------------------------------------------
    -  val driverClass = {
    -    val userSpecifiedDriverClass = parameters.get(JDBC_DRIVER_CLASS)
    -    userSpecifiedDriverClass.foreach(DriverRegistry.register)
    -
    -    // Performing this part of the logic on the driver guards against the corner-case where the
    -    // driver returned for a URL is different on the driver and executors due to classpath
    -    // differences.
    -    userSpecifiedDriverClass.getOrElse {
    -      DriverManager.getDriver(url).getClass.getCanonicalName
    -    }
    -  }
    +  val driverClass = parameters.get(JDBC_DRIVER_CLASS)
    --- End diff --
    
    Might be too late, but should these be private?
    Does it solve the issue to make this a def instead?


---
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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on th...

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

    https://github.com/apache/spark/pull/16678
  
    Thanks for the quick pull request!
    
    > @darabos Could you make a manual test and see whether this changes can resolve your issue?
    
    Unfortunately it does not. I built the code with this command:
    
    ```
    JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/ \
      ./dev/make-distribution.sh \
        -Phadoop-2.7 -Phive -Phive-thriftserver 
    ```
    
    I ran the commands in the pull request description in the fresh `spark-shell` and got the same errors. The stack trace reflects your changes though:
    
    ```
    scala> spark.read.format("jdbc").option("url", "jdbc:sqlite:").option("dbtable", "x").load
    java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getDriver(DriverManager.java:315)
      at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$2.apply(JdbcUtils.scala:55)
      at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$2.apply(JdbcUtils.scala:55)
      at scala.Option.getOrElse(Option.scala:121)
      at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.createConnectionFactory(JdbcUtils.scala:54)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:58)
      at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.<init>(JDBCRelation.scala:113)
      at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:47)
      at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:320)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:158)
      at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:126)
      ... 48 elided
    
    scala> spark.read.format("jdbc").option("url", "jdbc:sqlite:").option("dbtable", "x").load
    java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (no such table: x)
    ```
    
    Have you been unable to reproduce this on your machine? Do you think something's wrong with my environment?


---
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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on th...

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

    https://github.com/apache/spark/pull/16678
  
    @darabos Thank you! It confirms my guess. Let me think about it. Thanks!
    
    Because you will not enable Hive support, if you do not use `-Phive`. 


---
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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver...

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

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


---
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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on th...

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

    https://github.com/apache/spark/pull/16678
  
    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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on th...

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

    https://github.com/apache/spark/pull/16678
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/71836/
    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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on th...

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

    https://github.com/apache/spark/pull/16678
  
    **[Test build #71836 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71836/testReport)** for PR 16678 at commit [`9f5b11b`](https://github.com/apache/spark/commit/9f5b11ba8c30a6908186ba392c090e4e9439d21d).
     * This patch **fails Spark unit 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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on th...

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

    https://github.com/apache/spark/pull/16678
  
    **[Test build #71836 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/71836/testReport)** for PR 16678 at commit [`9f5b11b`](https://github.com/apache/spark/commit/9f5b11ba8c30a6908186ba392c090e4e9439d21d).


---
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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver...

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

    https://github.com/apache/spark/pull/16678#discussion_r97370977
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCOptions.scala ---
    @@ -73,17 +73,7 @@ class JDBCOptions(
       // ------------------------------------------------------------
       // Optional parameters
       // ------------------------------------------------------------
    -  val driverClass = {
    -    val userSpecifiedDriverClass = parameters.get(JDBC_DRIVER_CLASS)
    -    userSpecifiedDriverClass.foreach(DriverRegistry.register)
    -
    -    // Performing this part of the logic on the driver guards against the corner-case where the
    -    // driver returned for a URL is different on the driver and executors due to classpath
    -    // differences.
    -    userSpecifiedDriverClass.getOrElse {
    -      DriverManager.getDriver(url).getClass.getCanonicalName
    -    }
    -  }
    +  val driverClass = parameters.get(JDBC_DRIVER_CLASS)
    --- End diff --
    
    ```Scala
    spark.read.format("jdbc").option("url", "jdbc:sqlite:").option("dbtable", "x").load
    ```
    In the above code, it is not passing `JDBC_DRIVER_CLASS`. Thus, this does not help. 
    
    Actually, if @darabos passes `JDBC_DRIVER_CLASS` as an JDBC option, the problem is solved.  Thus, I suspect it is caused by the classloader. 


---
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 #16678: [SPARK-19209] [WIP] JDBC: Fix "No suitable driver" on th...

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

    https://github.com/apache/spark/pull/16678
  
    (I used `make-distribution.sh` because when I built with `build/mvn -DskipTests clean package` I could not reproduce the issue. I think `-Phive` is probably the culprit, but I have not experimented enough to know for sure.)


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