diff --git a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java index 7cc150ac90c..d1d77a26a5d 100644 --- a/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java +++ b/kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java @@ -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 @@ -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) { } 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 cb32bbd8d46..7faf6c2118d 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 @@ -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; @@ -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 = "."; @@ -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; } @@ -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.