This is an automated email from the ASF dual-hosted git repository.

yao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new eeb35f3  [KYUUBI #1131] Rename KyuubiDriver to KyuubiHiveDriver
eeb35f3 is described below

commit eeb35f31dde92a633da1208fc5365b91f66740e9
Author: Cheng Pan <[email protected]>
AuthorDate: Fri Sep 24 13:36:19 2021 +0800

    [KYUUBI #1131] Rename KyuubiDriver to KyuubiHiveDriver
    
    <!--
    Thanks for sending a pull request!
    
    Here are some tips for you:
      1. If this is your first time, please read our contributor guidelines: 
https://kyuubi.readthedocs.io/en/latest/community/contributions.html
      2. If the PR is related to an issue in 
https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your 
PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
      3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][KYUUBI #XXXX] Your PR title ...'.
    -->
    
    ### _Why are the changes needed?_
    <!--
    Please clarify why the changes are needed. For instance,
      1. If you add a feature, you can talk about the use case of it.
      2. If you fix a bug, you can clarify why it is a bug.
    -->
    This PR is based on discussion 
https://www.mail-archive.com/devkyuubi.apache.org/msg00977.html
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run 
test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #1147 from pan3793/jdbc-rename.
    
    Closes #1131
    
    500edae6 [Cheng Pan] Add javadoc
    bd9f94c2 [Cheng Pan] Add deprecated KyuubiDriver test
    d9688d8b [Cheng Pan] [KYUUBI #1131] Rename KyuubiDriver to KyuubiHiveDriver
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: Kent Yao <[email protected]>
---
 .../java/org/apache/kyuubi/jdbc/KyuubiDriver.java  | 25 +++++-----------------
 .../{KyuubiDriver.java => KyuubiHiveDriver.java}   |  8 +++++--
 .../kyuubi/jdbc/{ => hive}/KyuubiConnection.java   |  2 +-
 .../jdbc/{ => hive}/KyuubiDatabaseMetaData.java    |  2 +-
 .../resources/META-INF/services/java.sql.Driver    |  1 +
 ...iverSuite.scala => KyuubiHiveDriverSuite.scala} | 25 ++++++++++++++++++----
 6 files changed, 35 insertions(+), 28 deletions(-)

diff --git 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDriver.java 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDriver.java
index d4e8370..4238d52 100644
--- a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDriver.java
+++ b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDriver.java
@@ -17,24 +17,9 @@
 
 package org.apache.kyuubi.jdbc;
 
-import org.apache.hive.jdbc.HiveDriver;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.Properties;
-
-public class KyuubiDriver extends HiveDriver {
-    static {
-        try {
-            DriverManager.registerDriver(new KyuubiDriver());
-        } catch (SQLException e) {
-            throw new RuntimeException("Failed to register driver", e);
-        }
-    }
-
-    @Override
-    public Connection connect(String url, Properties info) throws SQLException 
{
-        return acceptsURL(url) ? new KyuubiConnection(url, info) : null;
-    }
+/**
+ * @deprecated Use `KyuubiHiveDriver` instead.
+ */
+@Deprecated
+public class KyuubiDriver extends KyuubiHiveDriver {
 }
diff --git 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDriver.java 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiHiveDriver.java
similarity index 83%
copy from 
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDriver.java
copy to 
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiHiveDriver.java
index d4e8370..a3ca8fb 100644
--- a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDriver.java
+++ 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiHiveDriver.java
@@ -18,16 +18,20 @@
 package org.apache.kyuubi.jdbc;
 
 import org.apache.hive.jdbc.HiveDriver;
+import org.apache.kyuubi.jdbc.hive.KyuubiConnection;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Properties;
 
-public class KyuubiDriver extends HiveDriver {
+/**
+ * Kyuubi JDBC driver to connect to Kyuubi server via HiveServer2 thrift 
protocol.
+ */
+public class KyuubiHiveDriver extends HiveDriver {
     static {
         try {
-            DriverManager.registerDriver(new KyuubiDriver());
+            DriverManager.registerDriver(new KyuubiHiveDriver());
         } catch (SQLException e) {
             throw new RuntimeException("Failed to register driver", e);
         }
diff --git 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiConnection.java 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java
similarity index 98%
rename from 
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiConnection.java
rename to 
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java
index c7a832a..bccecc3 100644
--- 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiConnection.java
+++ 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.kyuubi.jdbc;
+package org.apache.kyuubi.jdbc.hive;
 
 import java.lang.reflect.Field;
 import java.sql.DatabaseMetaData;
diff --git 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDatabaseMetaData.java
 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java
similarity index 98%
rename from 
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDatabaseMetaData.java
rename to 
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java
index 1a45bf9..435f0c7 100644
--- 
a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/KyuubiDatabaseMetaData.java
+++ 
b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.kyuubi.jdbc;
+package org.apache.kyuubi.jdbc.hive;
 
 import org.apache.hive.jdbc.HiveDatabaseMetaData;
 import org.apache.hive.jdbc.HiveQueryResultSet;
diff --git 
a/kyuubi-hive-jdbc/src/main/resources/META-INF/services/java.sql.Driver 
b/kyuubi-hive-jdbc/src/main/resources/META-INF/services/java.sql.Driver
index 6611c7e..ab16876 100644
--- a/kyuubi-hive-jdbc/src/main/resources/META-INF/services/java.sql.Driver
+++ b/kyuubi-hive-jdbc/src/main/resources/META-INF/services/java.sql.Driver
@@ -14,3 +14,4 @@
 # limitations under the License.
 
 org.apache.kyuubi.jdbc.KyuubiDriver
+org.apache.kyuubi.jdbc.KyuubiHiveDriver
diff --git 
a/kyuubi-hive-jdbc/src/test/scala/org/apache/kyuubi/jdbc/KyuubiDriverSuite.scala
 
b/kyuubi-hive-jdbc/src/test/scala/org/apache/kyuubi/jdbc/KyuubiHiveDriverSuite.scala
similarity index 76%
rename from 
kyuubi-hive-jdbc/src/test/scala/org/apache/kyuubi/jdbc/KyuubiDriverSuite.scala
rename to 
kyuubi-hive-jdbc/src/test/scala/org/apache/kyuubi/jdbc/KyuubiHiveDriverSuite.scala
index b1f6811..f6116a2 100644
--- 
a/kyuubi-hive-jdbc/src/test/scala/org/apache/kyuubi/jdbc/KyuubiDriverSuite.scala
+++ 
b/kyuubi-hive-jdbc/src/test/scala/org/apache/kyuubi/jdbc/KyuubiHiveDriverSuite.scala
@@ -22,10 +22,11 @@ import java.util.Properties
 import org.apache.kyuubi.IcebergSuiteMixin
 import org.apache.kyuubi.engine.spark.WithSparkSQLEngine
 import org.apache.kyuubi.engine.spark.shim.SparkCatalogShim
+import org.apache.kyuubi.jdbc.hive.{KyuubiConnection, KyuubiDatabaseMetaData}
 import org.apache.kyuubi.tags.IcebergTest
 
 @IcebergTest
-class KyuubiDriverSuite extends WithSparkSQLEngine with IcebergSuiteMixin {
+class KyuubiHiveDriverSuite extends WithSparkSQLEngine with IcebergSuiteMixin {
 
   override def withKyuubiConf: Map[String, String] = extraConfigs -
     "spark.sql.defaultCatalog" -
@@ -39,8 +40,8 @@ class KyuubiDriverSuite extends WithSparkSQLEngine with 
IcebergSuiteMixin {
   }
 
   test("get tables with kyuubi driver") {
-    val kyuubiDriver = new KyuubiDriver()
-    val connection = kyuubiDriver.connect(getJdbcUrl, new Properties())
+    val driver = new KyuubiHiveDriver()
+    val connection = driver.connect(getJdbcUrl, new Properties())
     assert(connection.isInstanceOf[KyuubiConnection])
     val metaData = connection.getMetaData
     assert(metaData.isInstanceOf[KyuubiDatabaseMetaData])
@@ -68,6 +69,22 @@ class KyuubiDriverSuite extends WithSparkSQLEngine with 
IcebergSuiteMixin {
       statement.close()
       connection.close()
     }
-    connection
+  }
+
+  test("deprecated KyuubiDriver also works") {
+    val driver = new KyuubiDriver()
+    val connection = driver.connect(getJdbcUrl, new Properties())
+    assert(connection.isInstanceOf[KyuubiConnection])
+    val metaData = connection.getMetaData
+    assert(metaData.isInstanceOf[KyuubiDatabaseMetaData])
+    val statement = connection.createStatement()
+    try {
+      val resultSet = statement.executeQuery(s"SELECT 1")
+      assert(resultSet.next())
+      assert(resultSet.getInt(1) === 1)
+    } finally {
+      statement.close()
+      connection.close()
+    }
   }
 }

Reply via email to