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

HIVE-15540: Impl DatabaseMetaData#getURL() and DatabaseMetaData#getUserName() for HiveServer2 JDBC Driver #5554

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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 @@ -18,8 +18,6 @@

package org.apache.hive.jdbc;

import org.apache.hive.jdbc.HiveConnection;
import org.apache.hive.jdbc.Utils;
import org.apache.hive.jdbc.Utils.JdbcConnectionParams;

import java.util.LinkedHashMap;
Expand Down Expand Up @@ -107,4 +105,16 @@ public void testHiveConnectionUdateServerHiveConf() {
.get(Utils.JdbcConnectionParams.HIVE_CONF_PREFIX + "hive.default.nulls.last"));

}

@Test
public void testGetUserName() throws SQLException {
HiveConnection hiveConnection = new HiveConnection("jdbc:hive2:///;user=foo", new Properties());
hiveDatabaseMetaData = new HiveDatabaseMetaData(hiveConnection, null, null);
assertEquals("foo", hiveDatabaseMetaData.getUserName());
}

@Test
public void testGetURL() {
assertEquals(connection.getConnectedUrl(), hiveDatabaseMetaData.getURL());
}
}
2 changes: 1 addition & 1 deletion jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ public void updateServerHiveConf(Map<String, String> serverHiveConf, JdbcConnect
/**
* @return username from sessConfMap
*/
private String getUserName() {
String getUserName() {
return getSessionValue(JdbcConnectionParams.AUTH_USER, JdbcConnectionParams.ANONYMOUS_USER);
}

Expand Down
8 changes: 4 additions & 4 deletions jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -744,12 +744,12 @@ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
};
}

public String getURL() throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported");
public String getURL() {
return connection.getConnectedUrl();
}

public String getUserName() throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported");
public String getUserName() {
return connection.getUserName();
}

public ResultSet getVersionColumns(String catalog, String schema, String table)
Expand Down
Loading