henrib commented on code in PR #5882:
URL: https://github.com/apache/hive/pull/5882#discussion_r2251813193


##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCachingCatalog.java:
##########
@@ -63,6 +62,27 @@ public List<Namespace> listNamespaces(Namespace nmspc) 
throws NoSuchNamespaceExc
     return hiveCatalog.listNamespaces(nmspc);
   }
 
+  @Override
+  public Table loadTable(TableIdentifier identifier) {
+    TableIdentifier canonicalIdentifier = identifier.toLowerCase();
+    Table cachedTable = tableCache.getIfPresent(canonicalIdentifier);
+    if (cachedTable != null) {
+      String location = hiveCatalog.getTableLocation(canonicalIdentifier);
+      if (location == null) {
+        LOG.debug("Table {} has no location, returning cached table without 
location", canonicalIdentifier);
+      } else if (!location.equals(cachedTable.location())) {
+        LOG.debug("Cached table {} has a different location than the one in 
the catalog: {} != {}",
+                 canonicalIdentifier, cachedTable.location(), location);
+      } else {
+        LOG.debug("Returning cached table: {}", canonicalIdentifier);
+        return cachedTable;
+      }
+      // Invalidate the cached table if the location is different
+      tableCache.invalidate(cachedTable);

Review Comment:
   Updated to a more robust and more efficient version.



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