[ https://issues.apache.org/jira/browse/HIVE-25102?focusedWorklogId=598647&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-598647 ]
ASF GitHub Bot logged work on HIVE-25102: ----------------------------------------- Author: ASF GitHub Bot Created on: 18/May/21 15:32 Start Date: 18/May/21 15:32 Worklog Time Spent: 10m Work Description: marton-bod commented on a change in pull request #2261: URL: https://github.com/apache/hive/pull/2261#discussion_r634500584 ########## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/Catalogs.java ########## @@ -284,4 +334,42 @@ private static String getCatalogType(Configuration conf, String catalogName) { } } } + + public static class TableCache { + private static final Cache<String, Table> tableCache = Caffeine.newBuilder() + .expireAfterAccess(12, TimeUnit.HOURS).build(); + private static final Logger LOG = LoggerFactory.getLogger(TableCache.class); + + public static void removeTables(Configuration conf) { + String queryId = conf.get(HiveConf.ConfVars.HIVEQUERYID.varname); + if (queryId != null && !queryId.isEmpty()) { + Set<String> queryKeys = tableCache.asMap().keySet().stream() + .filter(k -> k.startsWith(queryId)).collect(Collectors.toSet()); + tableCache.invalidateAll(queryKeys); + } else { + LOG.warn("Query id is not present in config, therefore no Iceberg table object is removed " + Review comment: I think what we do expect is that the `hive.query.id` is always populated in the config. If it's absent, that's a warning sign and something which could prevent us from evicting from the cache. This could be a useful log line in case we see that the cache gets overly large and we're looking for the root cause why the iceberg tables are not evicted. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 598647) Time Spent: 4h 10m (was: 4h) > Cache Iceberg table objects within same query > --------------------------------------------- > > Key: HIVE-25102 > URL: https://issues.apache.org/jira/browse/HIVE-25102 > Project: Hive > Issue Type: Improvement > Reporter: László Pintér > Assignee: László Pintér > Priority: Major > Labels: pull-request-available > Time Spent: 4h 10m > Remaining Estimate: 0h > > We run Catalogs.loadTable(configuration, props) plenty of times which is > costly. > We should: > - Cache it maybe even globally based on the queryId > - Make sure that the query uses one snapshot during the whole execution of a > single query -- This message was sent by Atlassian Jira (v8.3.4#803005)