You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2022/06/16 12:59:45 UTC
[incubator-kyuubi] branch master updated: [KYUUBI #2897] Remove Hive metastore dependencies from Kyuubi Hive JDBC
This is an automated email from the ASF dual-hosted git repository.
chengpan 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 62b6987af [KYUUBI #2897] Remove Hive metastore dependencies from Kyuubi Hive JDBC
62b6987af is described below
commit 62b6987af6760ca6e27976e3062ab35e50b76d7b
Author: Cheng Pan <ch...@apache.org>
AuthorDate: Thu Jun 16 20:59:35 2022 +0800
[KYUUBI #2897] Remove Hive metastore dependencies from Kyuubi Hive JDBC
### _Why are the changes needed?_
Remove Hive metastore dependencies from Kyuubi Hive JDBC, and minor improve the UT.
### _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
- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #2897 from pan3793/jdbc.
Closes #2897
31cb3068 [Cheng Pan] Remove Hive metastore dependencies from Kyuubi Hive JDBC
Authored-by: Cheng Pan <ch...@apache.org>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
kyuubi-hive-jdbc/pom.xml | 24 -------------------
.../kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java | 9 ++++---
.../kyuubi/jdbc/hive/KyuubiStatementTest.java | 28 +++++++++++-----------
.../apache/kyuubi/jdbc/hive/TestJdbcDriver.java | 11 +--------
.../jdbc/hive/TestKyuubiPreparedStatement.java | 17 +------------
5 files changed, 20 insertions(+), 69 deletions(-)
diff --git a/kyuubi-hive-jdbc/pom.xml b/kyuubi-hive-jdbc/pom.xml
index 42a1b03df..04130bf1a 100644
--- a/kyuubi-hive-jdbc/pom.xml
+++ b/kyuubi-hive-jdbc/pom.xml
@@ -100,30 +100,6 @@
</exclusions>
</dependency>
- <dependency>
- <groupId>org.apache.hive</groupId>
- <artifactId>hive-metastore</artifactId>
- <version>${hive.version}</version>
- <exclusions>
- <exclusion>
- <groupId>*</groupId>
- <artifactId>*</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.apache.hive</groupId>
- <artifactId>hive-standalone-metastore</artifactId>
- <version>${hive.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>*</artifactId>
- <groupId>*</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-llap-client</artifactId>
diff --git a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java
index aa4dd41b5..07a4ee4c0 100644
--- a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java
+++ b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java
@@ -28,7 +28,6 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.jar.Attributes;
-import org.apache.hadoop.hive.metastore.TableType;
import org.apache.hive.service.cli.GetInfoType;
import org.apache.hive.service.cli.HiveSQLException;
import org.apache.hive.service.rpc.thrift.*;
@@ -708,13 +707,13 @@ public class KyuubiDatabaseMetaData implements SQLDatabaseMetaData {
public static String toJdbcTableType(String hivetabletype) {
if (hivetabletype == null) {
return null;
- } else if (hivetabletype.equals(TableType.MANAGED_TABLE.toString())) {
+ } else if (hivetabletype.equals("MANAGED_TABLE")) {
return "TABLE";
- } else if (hivetabletype.equals(TableType.VIRTUAL_VIEW.toString())) {
+ } else if (hivetabletype.equals("VIRTUAL_VIEW")) {
return "VIEW";
- } else if (hivetabletype.equals(TableType.EXTERNAL_TABLE.toString())) {
+ } else if (hivetabletype.equals("EXTERNAL_TABLE")) {
return "EXTERNAL TABLE";
- } else if (hivetabletype.equals(TableType.MATERIALIZED_VIEW.toString())) {
+ } else if (hivetabletype.equals("MATERIALIZED_VIEW")) {
return "MATERIALIZED VIEW";
} else {
return hivetabletype;
diff --git a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/KyuubiStatementTest.java b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/KyuubiStatementTest.java
index 1d0acbbf5..04dc40e5c 100644
--- a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/KyuubiStatementTest.java
+++ b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/KyuubiStatementTest.java
@@ -26,32 +26,32 @@ public class KyuubiStatementTest {
@Test
public void testSetFetchSize1() throws SQLException {
- KyuubiStatement stmt = new KyuubiStatement(null, null, null);
- stmt.setFetchSize(123);
- assertEquals(123, stmt.getFetchSize());
+ try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
+ stmt.setFetchSize(123);
+ assertEquals(123, stmt.getFetchSize());
+ }
}
@Test
public void testSetFetchSize2() throws SQLException {
- KyuubiStatement stmt = new KyuubiStatement(null, null, null);
- int initial = stmt.getFetchSize();
- stmt.setFetchSize(0);
- assertEquals(initial, stmt.getFetchSize());
+ try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
+ int initial = stmt.getFetchSize();
+ stmt.setFetchSize(0);
+ assertEquals(initial, stmt.getFetchSize());
+ }
}
@Test(expected = SQLException.class)
public void testSetFetchSize3() throws SQLException {
- KyuubiStatement stmt = new KyuubiStatement(null, null, null);
- stmt.setFetchSize(-1);
+ try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
+ stmt.setFetchSize(-1);
+ }
}
- @Test
+ @Test(expected = SQLException.class)
public void testaddBatch() throws SQLException {
- KyuubiStatement stmt = new KyuubiStatement(null, null, null);
- try {
+ try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
stmt.addBatch(null);
- } catch (SQLException e) {
- assertEquals("java.sql.SQLFeatureNotSupportedException: Method not supported", e.toString());
}
}
}
diff --git a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestJdbcDriver.java b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestJdbcDriver.java
index 928a548f0..228ad00ee 100644
--- a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestJdbcDriver.java
+++ b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestJdbcDriver.java
@@ -27,7 +27,6 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -81,19 +80,11 @@ public class TestJdbcDriver {
@Test
public void testParseInitFile() throws IOException {
- BufferedWriter bw = null;
- try {
- bw = new BufferedWriter(new FileWriter(file));
+ try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
bw.write(input);
bw.flush();
assertEquals(
Arrays.asList(expected.split(",")), KyuubiConnection.parseInitFile(file.toString()));
- } catch (Exception e) {
- Assert.fail("Test was failed due to " + e);
- } finally {
- if (bw != null) {
- bw.close();
- }
}
}
}
diff --git a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestKyuubiPreparedStatement.java b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestKyuubiPreparedStatement.java
index 04c8ff8a3..522c209e7 100644
--- a/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestKyuubiPreparedStatement.java
+++ b/kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestKyuubiPreparedStatement.java
@@ -23,16 +23,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.sql.SQLException;
+import org.apache.hive.service.rpc.thrift.*;
import org.apache.hive.service.rpc.thrift.TCLIService.Iface;
-import org.apache.hive.service.rpc.thrift.TExecuteStatementReq;
-import org.apache.hive.service.rpc.thrift.TExecuteStatementResp;
-import org.apache.hive.service.rpc.thrift.TGetOperationStatusReq;
-import org.apache.hive.service.rpc.thrift.TGetOperationStatusResp;
-import org.apache.hive.service.rpc.thrift.TOperationHandle;
-import org.apache.hive.service.rpc.thrift.TOperationState;
-import org.apache.hive.service.rpc.thrift.TSessionHandle;
-import org.apache.hive.service.rpc.thrift.TStatus;
-import org.apache.hive.service.rpc.thrift.TStatusCode;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -65,7 +57,6 @@ public class TestKyuubiPreparedStatement {
when(client.ExecuteStatement(any(TExecuteStatementReq.class))).thenReturn(tExecStatementResp);
}
- @SuppressWarnings("resource")
@Test
public void testNonParameterized() throws Exception {
String sql = "select 1";
@@ -78,7 +69,6 @@ public class TestKyuubiPreparedStatement {
assertEquals("select 1", argument.getValue().getStatement());
}
- @SuppressWarnings("resource")
@Test
public void unusedArgument() throws Exception {
String sql = "select 1";
@@ -87,7 +77,6 @@ public class TestKyuubiPreparedStatement {
ps.execute();
}
- @SuppressWarnings("resource")
@Test(expected = SQLException.class)
public void unsetArgument() throws Exception {
String sql = "select 1 from x where a=?";
@@ -95,7 +84,6 @@ public class TestKyuubiPreparedStatement {
ps.execute();
}
- @SuppressWarnings("resource")
@Test
public void oneArgument() throws Exception {
String sql = "select 1 from x where a=?";
@@ -109,7 +97,6 @@ public class TestKyuubiPreparedStatement {
assertEquals("select 1 from x where a='asd'", argument.getValue().getStatement());
}
- @SuppressWarnings("resource")
@Test
public void escapingOfStringArgument() throws Exception {
String sql = "select 1 from x where a=?";
@@ -123,7 +110,6 @@ public class TestKyuubiPreparedStatement {
assertEquals("select 1 from x where a='a\\'\"d'", argument.getValue().getStatement());
}
- @SuppressWarnings("resource")
@Test
public void pastingIntoQuery() throws Exception {
String sql = "select 1 from x where a='e' || ?";
@@ -138,7 +124,6 @@ public class TestKyuubiPreparedStatement {
}
// HIVE-13625
- @SuppressWarnings("resource")
@Test
public void pastingIntoEscapedQuery() throws Exception {
String sql = "select 1 from x where a='\\044e' || ?";