Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional call GetInfo CLI_ODBC_KEYWORDS to restore compatible with lower version Kyuubi and HS2 #6016

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading