Skip to content

Commit

Permalink
Conditional call GetInfo CLI_ODBC_KEYWORDS to restore compatible with…
Browse files Browse the repository at this point in the history
… lower version Kyuubi and HS2
  • Loading branch information
pan3793 committed Jan 25, 2024
1 parent ac388d1 commit 413c7a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ public DatabaseMetaData getMetaData() throws SQLException {
if (isClosed) {
throw new KyuubiSQLException("Connection is closed");
}
return new KyuubiDatabaseMetaData(this, client, sessHandle);
return new KyuubiDatabaseMetaData(this, protocol, client, sessHandle);
}

@Override
Expand Down Expand Up @@ -1179,7 +1179,7 @@ public boolean isValid(int timeout) throws SQLException {
}
boolean rc = false;
try {
new KyuubiDatabaseMetaData(this, client, sessHandle).getDatabaseProductName();
new KyuubiDatabaseMetaData(this, protocol, client, sessHandle).getDatabaseProductName();
rc = true;
} catch (SQLException ignore) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@

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

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
Expand All @@ -37,6 +34,7 @@
public class KyuubiDatabaseMetaData implements SQLDatabaseMetaData {

private final KyuubiConnection connection;
private final TProtocolVersion protocol;
private final TCLIService.Iface client;
private final TSessionHandle sessHandle;
private static final String CATALOG_SEPARATOR = ".";
Expand All @@ -50,8 +48,12 @@ public class KyuubiDatabaseMetaData implements SQLDatabaseMetaData {
private String dbVersion = null;

public KyuubiDatabaseMetaData(
KyuubiConnection connection, TCLIService.Iface client, TSessionHandle sessHandle) {
KyuubiConnection connection,
TProtocolVersion protocol,
TCLIService.Iface client,
TSessionHandle sessHandle) {
this.connection = connection;
this.protocol = protocol;
this.client = client;
this.sessHandle = sessHandle;
}
Expand Down Expand Up @@ -568,6 +570,12 @@ public ResultSet getProcedures(String catalog, String schemaPattern, String proc

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

0 comments on commit 413c7a4

Please sign in to comment.