deniskuzZ commented on code in PR #6961:
URL: https://github.com/apache/hive/pull/6961#discussion_r4669987903
##########
ql/src/test/org/apache/hadoop/hive/ql/metadata/TestSessionHiveMetaStoreClientQueryCache.java:
##########
@@ -201,6 +202,35 @@ public void testMissingTableLookedUpOncePerQuery() throws
Exception {
verify(delegate, times(2)).getTable(any(GetTableRequest.class));
}
+ @Test
+ public void testMissingTableLookedUpAgainAfterExecution() throws Exception {
+ String queryId = "test_missing_table_after_execution";
+ HiveConf conf = startQuery(queryId);
+ IMetaStoreClient delegate = tableDelegate();
+ // CTAS: the target is missing at compile time, then created by a task
while the cache is disabled
+ when(delegate.getTable(any(GetTableRequest.class)))
+ .thenThrow(new NoSuchObjectException("db.t not found"))
+ .thenReturn(new Table());
+ SessionHiveMetaStoreClient client =
SessionHiveMetaStoreClient.newClient(conf, delegate);
+
+ try {
+ client.getTable(hiveGetTableRequest());
+ fail("table should not be found");
+ } catch (NoSuchObjectException e) {
+ // compile time: the target does not exist yet
+ }
+
+ // as Executor.execute does around runTasks
Review Comment:
````
/** Looks up the created table by name, as a post-execution hook would. */
public static class LookupCreatedTableHook implements
ExecuteWithHookContext {
static org.apache.hadoop.hive.ql.metadata.Table found;
@Override
public void run(HookContext hookContext) throws Exception {
found = Hive.get().getTable("default", "query_cache_created_table");
}
}
@Test
public void testPostExecHookFindsTableCreatedByQuery() throws Exception {
HiveConf conf = new HiveConfForTest(getClass());
conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
conf.setBoolVar(HiveConf.ConfVars.HIVE_OPTIMIZE_HMS_QUERY_CACHE_ENABLED,
true);
conf.setVar(HiveConf.ConfVars.POST_EXEC_HOOKS,
LookupCreatedTableHook.class.getName());
SessionState.start(conf);
Driver driver = new Driver(conf);
LookupCreatedTableHook.found = null;
try {
// IF NOT EXISTS: the analyzer looks the table up at compile time and
caches it as not found
driver.run("create table if not exists query_cache_created_table (i
int)");
assertNotNull(LookupCreatedTableHook.found);
} finally {
driver.run("drop table if exists query_cache_created_table");
}
}
````
--
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]