ayushtkn commented on code in PR #6969:
URL: https://github.com/apache/hive/pull/6969#discussion_r4639718417
##########
ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/HivePrivilegeObject.java:
##########
@@ -110,12 +113,20 @@ private int compare(Collection<String> o1,
Collection<String> o2) {
}
/**
- * Try to get thread local configuration from HMSHandler, otherwise create a
new one.
- * @return configuration
+ * @return the given catalog name if not blank, otherwise the current
catalog of the session in HS2,
+ * or the default catalog from the HMSHandler configuration (or a new
metastore configuration).
*/
- public static Configuration getConf() {
- return HMSHandlerContext.getConfiguration()
- .orElse(new Configuration());
+ private String getCatalogOrDefault(String catName) {
+ if (StringUtils.isNotBlank(catName)) {
+ return catName;
+ } else if (SessionState.get() != null) {
+ // HS2
+ return SessionState.get().getCurrentCatalog();
+ }
Review Comment:
Thanx @dengzhhu653
Keeping the session catalog in the builder is fine — it matches
HiveTableName.of() and the SQL paths.
The read still has to use that same catalog. On master a null catName became
MetaStoreUtils.getDefaultCatalog(getConf()), which is what the catalog-less
client calls use, so GET_COLUMNS authorized and read the same catalog. After
this change a null catName is the session catalog, but getDatabases(pattern) /
getTables / getSchema / getPrimaryKeys still use the metastore default.
Please resolve it once, from the session when catalogName is null:
String cat = StringUtils.isNotBlank(catalogName)
? catalogName
: SessionState.get().getCurrentCatalog();
and pass cat to the catalog-aware metastore calls and to the privilege
object. GetTablesOperation has the same split (getDatabases is called twice,
lines 110 and 118, plus getTableMeta at 120) and isn't in this PR — it needs
the same fix here.
PS. Non Blocking, just validate it, If it is f9, feel free to merge or a
followup or whichever way you feel correct :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]