Skip to content

Commit 413c7a4

Browse files
committed
Conditional call GetInfo CLI_ODBC_KEYWORDS to restore compatible with lower version Kyuubi and HS2
1 parent ac388d1 commit 413c7a4

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ public DatabaseMetaData getMetaData() throws SQLException {
11321132
if (isClosed) {
11331133
throw new KyuubiSQLException("Connection is closed");
11341134
}
1135-
return new KyuubiDatabaseMetaData(this, client, sessHandle);
1135+
return new KyuubiDatabaseMetaData(this, protocol, client, sessHandle);
11361136
}
11371137

11381138
@Override
@@ -1179,7 +1179,7 @@ public boolean isValid(int timeout) throws SQLException {
11791179
}
11801180
boolean rc = false;
11811181
try {
1182-
new KyuubiDatabaseMetaData(this, client, sessHandle).getDatabaseProductName();
1182+
new KyuubiDatabaseMetaData(this, protocol, client, sessHandle).getDatabaseProductName();
11831183
rc = true;
11841184
} catch (SQLException ignore) {
11851185
}

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

+13-5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919

2020
import static org.apache.kyuubi.shaded.hive.service.rpc.thrift.TTypeId.*;
2121

22-
import java.sql.Connection;
23-
import java.sql.DatabaseMetaData;
24-
import java.sql.ResultSet;
25-
import java.sql.SQLException;
22+
import java.sql.*;
2623
import java.util.ArrayList;
2724
import java.util.Arrays;
2825
import java.util.Comparator;
@@ -37,6 +34,7 @@
3734
public class KyuubiDatabaseMetaData implements SQLDatabaseMetaData {
3835

3936
private final KyuubiConnection connection;
37+
private final TProtocolVersion protocol;
4038
private final TCLIService.Iface client;
4139
private final TSessionHandle sessHandle;
4240
private static final String CATALOG_SEPARATOR = ".";
@@ -50,8 +48,12 @@ public class KyuubiDatabaseMetaData implements SQLDatabaseMetaData {
5048
private String dbVersion = null;
5149

5250
public KyuubiDatabaseMetaData(
53-
KyuubiConnection connection, TCLIService.Iface client, TSessionHandle sessHandle) {
51+
KyuubiConnection connection,
52+
TProtocolVersion protocol,
53+
TCLIService.Iface client,
54+
TSessionHandle sessHandle) {
5455
this.connection = connection;
56+
this.protocol = protocol;
5557
this.client = client;
5658
this.sessHandle = sessHandle;
5759
}
@@ -568,6 +570,12 @@ public ResultSet getProcedures(String catalog, String schemaPattern, String proc
568570

569571
@Override
570572
public String getSQLKeywords() throws SQLException {
573+
if (protocol.compareTo(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V11) < 0) {
574+
throw new SQLFeatureNotSupportedException(
575+
String.format(
576+
"Feature is not supported, protocol version is %s, requires %s or higher",
577+
protocol, TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V11));
578+
}
571579
// Note: the definitions of what ODBC and JDBC keywords exclude are different in different
572580
// places. For now, just return the ODBC version here; that excludes Hive keywords
573581
// that are also ODBC reserved keywords. We could also exclude SQL:2003.

0 commit comments

Comments
 (0)