Skip to content

Commit 62b6987

Browse files
committed
[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 31cb306 [Cheng Pan] Remove Hive metastore dependencies from Kyuubi Hive JDBC Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Cheng Pan <chengpan@apache.org>
1 parent e3bf604 commit 62b6987

File tree

5 files changed

+20
-69
lines changed

5 files changed

+20
-69
lines changed

kyuubi-hive-jdbc/pom.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -100,30 +100,6 @@
100100
</exclusions>
101101
</dependency>
102102

103-
<dependency>
104-
<groupId>org.apache.hive</groupId>
105-
<artifactId>hive-metastore</artifactId>
106-
<version>${hive.version}</version>
107-
<exclusions>
108-
<exclusion>
109-
<groupId>*</groupId>
110-
<artifactId>*</artifactId>
111-
</exclusion>
112-
</exclusions>
113-
</dependency>
114-
115-
<dependency>
116-
<groupId>org.apache.hive</groupId>
117-
<artifactId>hive-standalone-metastore</artifactId>
118-
<version>${hive.version}</version>
119-
<exclusions>
120-
<exclusion>
121-
<artifactId>*</artifactId>
122-
<groupId>*</groupId>
123-
</exclusion>
124-
</exclusions>
125-
</dependency>
126-
127103
<dependency>
128104
<groupId>org.apache.hive</groupId>
129105
<artifactId>hive-llap-client</artifactId>

kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiDatabaseMetaData.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.Comparator;
2929
import java.util.List;
3030
import java.util.jar.Attributes;
31-
import org.apache.hadoop.hive.metastore.TableType;
3231
import org.apache.hive.service.cli.GetInfoType;
3332
import org.apache.hive.service.cli.HiveSQLException;
3433
import org.apache.hive.service.rpc.thrift.*;
@@ -708,13 +707,13 @@ public int compare(JdbcTable o1, JdbcTable o2) {
708707
public static String toJdbcTableType(String hivetabletype) {
709708
if (hivetabletype == null) {
710709
return null;
711-
} else if (hivetabletype.equals(TableType.MANAGED_TABLE.toString())) {
710+
} else if (hivetabletype.equals("MANAGED_TABLE")) {
712711
return "TABLE";
713-
} else if (hivetabletype.equals(TableType.VIRTUAL_VIEW.toString())) {
712+
} else if (hivetabletype.equals("VIRTUAL_VIEW")) {
714713
return "VIEW";
715-
} else if (hivetabletype.equals(TableType.EXTERNAL_TABLE.toString())) {
714+
} else if (hivetabletype.equals("EXTERNAL_TABLE")) {
716715
return "EXTERNAL TABLE";
717-
} else if (hivetabletype.equals(TableType.MATERIALIZED_VIEW.toString())) {
716+
} else if (hivetabletype.equals("MATERIALIZED_VIEW")) {
718717
return "MATERIALIZED VIEW";
719718
} else {
720719
return hivetabletype;

kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/KyuubiStatementTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ public class KyuubiStatementTest {
2626

2727
@Test
2828
public void testSetFetchSize1() throws SQLException {
29-
KyuubiStatement stmt = new KyuubiStatement(null, null, null);
30-
stmt.setFetchSize(123);
31-
assertEquals(123, stmt.getFetchSize());
29+
try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
30+
stmt.setFetchSize(123);
31+
assertEquals(123, stmt.getFetchSize());
32+
}
3233
}
3334

3435
@Test
3536
public void testSetFetchSize2() throws SQLException {
36-
KyuubiStatement stmt = new KyuubiStatement(null, null, null);
37-
int initial = stmt.getFetchSize();
38-
stmt.setFetchSize(0);
39-
assertEquals(initial, stmt.getFetchSize());
37+
try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
38+
int initial = stmt.getFetchSize();
39+
stmt.setFetchSize(0);
40+
assertEquals(initial, stmt.getFetchSize());
41+
}
4042
}
4143

4244
@Test(expected = SQLException.class)
4345
public void testSetFetchSize3() throws SQLException {
44-
KyuubiStatement stmt = new KyuubiStatement(null, null, null);
45-
stmt.setFetchSize(-1);
46+
try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
47+
stmt.setFetchSize(-1);
48+
}
4649
}
4750

48-
@Test
51+
@Test(expected = SQLException.class)
4952
public void testaddBatch() throws SQLException {
50-
KyuubiStatement stmt = new KyuubiStatement(null, null, null);
51-
try {
53+
try (KyuubiStatement stmt = new KyuubiStatement(null, null, null)) {
5254
stmt.addBatch(null);
53-
} catch (SQLException e) {
54-
assertEquals("java.sql.SQLFeatureNotSupportedException: Method not supported", e.toString());
5555
}
5656
}
5757
}

kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestJdbcDriver.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Arrays;
2828
import java.util.Collection;
2929
import org.junit.AfterClass;
30-
import org.junit.Assert;
3130
import org.junit.BeforeClass;
3231
import org.junit.Test;
3332
import org.junit.runner.RunWith;
@@ -81,19 +80,11 @@ public static void cleanUpAfterClass() throws Exception {
8180

8281
@Test
8382
public void testParseInitFile() throws IOException {
84-
BufferedWriter bw = null;
85-
try {
86-
bw = new BufferedWriter(new FileWriter(file));
83+
try (BufferedWriter bw = new BufferedWriter(new FileWriter(file))) {
8784
bw.write(input);
8885
bw.flush();
8986
assertEquals(
9087
Arrays.asList(expected.split(",")), KyuubiConnection.parseInitFile(file.toString()));
91-
} catch (Exception e) {
92-
Assert.fail("Test was failed due to " + e);
93-
} finally {
94-
if (bw != null) {
95-
bw.close();
96-
}
9788
}
9889
}
9990
}

kyuubi-hive-jdbc/src/test/java/org/apache/kyuubi/jdbc/hive/TestKyuubiPreparedStatement.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,8 @@
2323
import static org.mockito.Mockito.when;
2424

2525
import java.sql.SQLException;
26+
import org.apache.hive.service.rpc.thrift.*;
2627
import org.apache.hive.service.rpc.thrift.TCLIService.Iface;
27-
import org.apache.hive.service.rpc.thrift.TExecuteStatementReq;
28-
import org.apache.hive.service.rpc.thrift.TExecuteStatementResp;
29-
import org.apache.hive.service.rpc.thrift.TGetOperationStatusReq;
30-
import org.apache.hive.service.rpc.thrift.TGetOperationStatusResp;
31-
import org.apache.hive.service.rpc.thrift.TOperationHandle;
32-
import org.apache.hive.service.rpc.thrift.TOperationState;
33-
import org.apache.hive.service.rpc.thrift.TSessionHandle;
34-
import org.apache.hive.service.rpc.thrift.TStatus;
35-
import org.apache.hive.service.rpc.thrift.TStatusCode;
3628
import org.junit.Before;
3729
import org.junit.Test;
3830
import org.mockito.ArgumentCaptor;
@@ -65,7 +57,6 @@ public void before() throws Exception {
6557
when(client.ExecuteStatement(any(TExecuteStatementReq.class))).thenReturn(tExecStatementResp);
6658
}
6759

68-
@SuppressWarnings("resource")
6960
@Test
7061
public void testNonParameterized() throws Exception {
7162
String sql = "select 1";
@@ -78,7 +69,6 @@ public void testNonParameterized() throws Exception {
7869
assertEquals("select 1", argument.getValue().getStatement());
7970
}
8071

81-
@SuppressWarnings("resource")
8272
@Test
8373
public void unusedArgument() throws Exception {
8474
String sql = "select 1";
@@ -87,15 +77,13 @@ public void unusedArgument() throws Exception {
8777
ps.execute();
8878
}
8979

90-
@SuppressWarnings("resource")
9180
@Test(expected = SQLException.class)
9281
public void unsetArgument() throws Exception {
9382
String sql = "select 1 from x where a=?";
9483
KyuubiPreparedStatement ps = new KyuubiPreparedStatement(connection, client, sessHandle, sql);
9584
ps.execute();
9685
}
9786

98-
@SuppressWarnings("resource")
9987
@Test
10088
public void oneArgument() throws Exception {
10189
String sql = "select 1 from x where a=?";
@@ -109,7 +97,6 @@ public void oneArgument() throws Exception {
10997
assertEquals("select 1 from x where a='asd'", argument.getValue().getStatement());
11098
}
11199

112-
@SuppressWarnings("resource")
113100
@Test
114101
public void escapingOfStringArgument() throws Exception {
115102
String sql = "select 1 from x where a=?";
@@ -123,7 +110,6 @@ public void escapingOfStringArgument() throws Exception {
123110
assertEquals("select 1 from x where a='a\\'\"d'", argument.getValue().getStatement());
124111
}
125112

126-
@SuppressWarnings("resource")
127113
@Test
128114
public void pastingIntoQuery() throws Exception {
129115
String sql = "select 1 from x where a='e' || ?";
@@ -138,7 +124,6 @@ public void pastingIntoQuery() throws Exception {
138124
}
139125

140126
// HIVE-13625
141-
@SuppressWarnings("resource")
142127
@Test
143128
public void pastingIntoEscapedQuery() throws Exception {
144129
String sql = "select 1 from x where a='\\044e' || ?";

0 commit comments

Comments
 (0)