-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Conversation
598a367
to
13fca4f
Compare
DatabaseMetaData#getURL()
and DatabaseMetaData#getUserName()
for HiveServer2 JDBC DriverDatabaseMetaData#getURL()
and DatabaseMetaData#getUserName()
for HiveServer2 JDBC Driver
I just looked into the jdbc driver recently and got surprised similarly as you. Can I ask you to add some tests around the changes? I think |
} | ||
|
||
public String getUserName() throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Method not supported"); | ||
return connection.getConnParams().getSessionVars().get("user"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more bullet-proof to get the user name similar way as HiveConnection does: It gets the username, or it is not provided, gives back the anonymous:
/**
* @return username from sessConfMap
*/
private String getUserName() {
return getSessionValue(JdbcConnectionParams.AUTH_USER, JdbcConnectionParams.ANONYMOUS_USER);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HiveConnection#getSessionValue(String, String)
andHiveConnection#getUserName()
are both private methods. I guess what you mean is?
public String getUserName() throws SQLException {
String username = connection.getConnParams().getSessionVars().get(JdbcConnectionParams.AUTH_USER);
if ((username == null) || username.isEmpty()) {
username = JdbcConnectionParams.ANONYMOUS_USER;
}
return username;
}
- Changing the
org.apache.hive.jdbc.TestJdbcDriver
doesn't seem intuitive enough, should I create aorg.apache.hive.jdbc.TestHiveDatabaseMetaData
class? - By the way, Jenkins used by Hive limits a single PR to 5 hours between two CIs, and the current PR's github tag is a bit inconsistent with the actual situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HiveConnection#getSessionValue(String, String) and HiveConnection#getUserName() are both private methods. I guess what you mean is?
Yes, something like that.
Changing the org.apache.hive.jdbc.TestJdbcDriver doesn't seem intuitive enough, should I create a org.apache.hive.jdbc.TestHiveDatabaseMetaData class?
Excuse me, wrong copy-paste. So, there is already a test class here: https://github.com/apache/hive/blob/master/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestHiveDatabaseMetaData.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I added new unit tests. I guess Hive Doc does not prohibit the use of Guava's utility classes in unit tests.
- I must admit that I found the Hive Contributor Guide on ASF Confluence to be out of date, and I had to spend some time looking up how to start a single unit test locally.
sdk install java 8.0.422-tem
sdk use java 8.0.422-tem
sdk install maven
mvn clean install -DskipTests -Pitests
mvn test -Dtest=TestHiveDatabaseMetaData -Dtest.output.overwrite=true -pl itests/hive-unit -Pitests
13fca4f
to
5cdac26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you for the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I just did a quick check of https://ci.hive.apache.org/blue/organizations/jenkins/hive-precommit/activity and found that unit tests for
TestMiniLlapLocalCliDriver
are failing in all recent PRs. Is there a quicker way to complete the tests mentioned in https://ci.hive.apache.org/blue/organizations/jenkins/hive-precommit/detail/PR-5554/2/tests than the following command?
sdk install java 8.0.422-tem
sdk use java 8.0.422-tem
sdk install maven
mvn clean install -DskipTests -Pitests
mvn test -Dtest=TestMiniLlapLocalCliDriver -Dtest.output.overwrite=true -pl itests/qtest -Pitests
- Update in 2024.11.24: See HIVE-28636: partition_explain_ddl.q is flaky #5555 .
- Update in 2024.11.25: See 2bf6614 .
- Update in 2024.11.26: I just did a quick check of https://ci.hive.apache.org/blue/organizations/jenkins/hive-precommit/activity and found that unit tests for
TestIcebergLlapLocalCompactorCliDriver
are failing in all recent PRs.....The master branch still seems to have problems. - Update in 2024.11.27: See a79922e .
5cdac26
to
297f166
Compare
297f166
to
9f2a3e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, rest looks good
import org.junit.Before; | ||
import org.junit.Test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just avoid changing the import order, just makes things complicated while backporting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
public String getUserName() throws SQLException { | ||
throw new SQLFeatureNotSupportedException("Method not supported"); | ||
String userName = connection.getConnParams().getSessionVars().get(JdbcConnectionParams.AUTH_USER); | ||
if ((userName == null) || userName.isEmpty()) { | ||
userName = JdbcConnectionParams.ANONYMOUS_USER; | ||
} | ||
return userName; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we just do
public String getUserName() throws SQLException {
return connection.getUserName();
}
and make getUserName()
in HiveConnection
package-private (default)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…tUserName()` for HiveServer2 JDBC Driver
9f2a3e2
to
edf9bda
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What changes were proposed in this pull request?
DatabaseMetaData#getURL()
andDatabaseMetaData#getUserName()
for HiveServer2 JDBC Driver.Why are the changes needed?
DatabaseMetaData#getURL()
andDatabaseMetaData#getUserName()
are not implemented for HiveServer2 JDBC Driver in Support connecting to HiveServer2 through database connection pools other than HikariCP shardingsphere#33762 and Improve GraalVM Reachability Metadata and corresponding nativeTest related unit tests shardingsphere#29052 . This leads to funny logic like the following.Does this PR introduce any user-facing change?
Is the change a dependency upgrade?
How was this patch tested?
sdk install java 8.0.422-tem sdk use java 8.0.422-tem sdk install maven mvn clean install -DskipTests -Pitests mvn test -Dtest=TestHiveDatabaseMetaData -Dtest.output.overwrite=true -pl itests/hive-unit -Pitests