deniskuzZ commented on code in PR #6961:
URL: https://github.com/apache/hive/pull/6961#discussion_r4679693601
##########
ql/src/java/org/apache/hadoop/hive/ql/metadata/HiveMetaStoreClientWithLocalCache.java:
##########
@@ -441,14 +443,34 @@ public GetPartitionsByNamesResult
getPartitionsByNames(GetPartitionsByNamesReque
return delegate.getPartitionsByNames(req);
}
+ /**
+ * The table for a cache watermark (its id) or the transactional check. It
is usually in the query-level cache
+ * already, as the compiler loaded it; the getTable of this class is below
that cache and would go to HMS.
+ */
+ private Table getTableForWatermark(String catName, String dbName, String
tblName) throws TException {
+ String cat = (catName == null || catName.isEmpty()) ?
getDefaultCatalog(conf) : catName;
+ Map<Object, Object> queryCache = SessionState.get() != null ?
+
SessionState.get().getQueryCache(MetaStoreClientCacheUtils.getQueryId()) : null;
+ if (queryCache == null) {
+ return getTable(cat, dbName, tblName);
+ }
+ CacheKey cacheKey = MetaStoreClientCacheUtils.tableByNameKey(cat, dbName,
tblName);
+ Table table = (Table) queryCache.get(cacheKey);
+ if (table == null) {
+ table = getTable(cat, dbName, tblName);
+ queryCache.put(cacheKey, table);
+ }
+ return table;
+ }
+
// cf. SessionHiveMetaStoreClient.getValidWriteIdList
private String getValidWriteIdList(String dbName, String tblName) {
try {
final String validTxnsList =
Hive.get().getConf().get(ValidTxnList.VALID_TXNS_KEY);
if (validTxnsList == null) {
return HiveMetaStoreClientUtils.getValidWriteIdList(dbName, tblName,
conf);
}
- if (!AcidUtils.isTransactionalTable(getTable(dbName, tblName))) {
+ if (!AcidUtils.isTransactionalTable(getTableForWatermark(null, dbName,
tblName))) {
Review Comment:
All three callers have catName and pass it to getTableForWatermark right
after this call.
Could getValidWriteIdList take it too, instead of null? Otherwise a
non-default-catalog request checks the default catalog's table for
isTransactionalTable.
````
TableWatermark watermark = new TableWatermark(
getValidWriteIdList(dbName, tableName), // check runs
on the default catalog's table
getTableForWatermark(catName, dbName, tableName).getId()); // id comes
from the requested catalog
------
private String getValidWriteIdList(String catName, String dbName, String
tblName) {
...
if (!AcidUtils.isTransactionalTable(getTableForWatermark(catName, dbName,
tblName))) {
````
--
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]