zabetak commented on code in PR #6064:
URL: https://github.com/apache/hive/pull/6064#discussion_r2340481991


##########
ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java:
##########
@@ -671,10 +672,20 @@ public void notifyTableChanged(String dbName, String 
tableName, long updateTime)
    */
   private boolean entryMatches(LookupInfo lookupInfo, CacheEntry entry, 
Set<CacheEntry> entriesToRemove) {
     QueryInfo queryInfo = entry.getQueryInfo();
+
+    Set<Long> cacheTableIds = new HashSet<>();
     for (ReadEntity readEntity : queryInfo.getInputs()) {
-      // Check that the tables used do not resolve to temp tables.
       if (readEntity.getType() == Type.TABLE) {
         Table tableUsed = readEntity.getTable();
+        // we want that the lookupInfo.tableIds are all covered by the table 
ids of the cache entry
+        // the query is used as cache key, so the lookup and the entry should 
use the same number of tables
+        // so it is enough to check whether every cache table id is contained 
in the lookup
+        if (!lookupInfo.tableIds.contains(tableUsed.getTTable().getId())) {
+          LOG.debug("Cached query not valid as it does not provide all table 
ids: expected {} but was {}", lookupInfo.tableIds, cacheTableIds);

Review Comment:
   The `cacheTableIds` is always empty. Apart from that, I would simplify also 
a bit the message:
   ```suggestion
             LOG.debug("Cache entry contains a table (tableId={}) that is not 
present in the query", tableUsed.getTTable().getId());
   ```



##########
ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java:
##########
@@ -671,10 +672,20 @@ public void notifyTableChanged(String dbName, String 
tableName, long updateTime)
    */
   private boolean entryMatches(LookupInfo lookupInfo, CacheEntry entry, 
Set<CacheEntry> entriesToRemove) {
     QueryInfo queryInfo = entry.getQueryInfo();
+
+    Set<Long> cacheTableIds = new HashSet<>();

Review Comment:
   The set variable is redundant and always empty.



-- 
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]

Reply via email to