use of io.prestosql.sql.tree.DropCache in project hetu-core by openlookeng.
the class TestSqlParser method testDropCache.
@Test
public void testDropCache() {
assertStatement("DROP CACHE a", new DropCache(QualifiedName.of("a"), false));
assertStatement("DROP CACHE a.b", new DropCache(QualifiedName.of("a", "b"), false));
assertStatement("DROP CACHE a.b.c", new DropCache(QualifiedName.of("a", "b", "c"), false));
assertStatement("DROP CACHE IF EXISTS a", new DropCache(QualifiedName.of("a"), true));
assertStatement("DROP CACHE IF EXISTS a.b", new DropCache(QualifiedName.of("a", "b"), true));
assertStatement("DROP CACHE IF EXISTS a.b.c", new DropCache(QualifiedName.of("a", "b", "c"), true));
}
use of io.prestosql.sql.tree.DropCache in project hetu-core by openlookeng.
the class TestDropCacheTask method testDropWithNonQualifiedName.
@Test
public void testDropWithNonQualifiedName() {
QualifiedName tableName = QualifiedName.of(table3);
QualifiedName fullName = QualifiedName.of(CATALOG_NAME, schema, table3);
DropCache statement = new DropCache(tableName, true);
Session session = testSessionBuilder().setTransactionId(transactionManager.beginTransaction(false)).setCatalog(CATALOG_NAME).setSchema(schema).build();
QueryStateMachine queryStateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
getFutureValue(new DropCacheTask().execute(statement, createTestTransactionManager(), metadata, new AllowAllAccessControl(), queryStateMachine, Collections.emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
assertFalse(SplitCacheMap.getInstance().cacheExists(fullName));
}
use of io.prestosql.sql.tree.DropCache in project hetu-core by openlookeng.
the class TestDropCacheTask method testDropCacheNotExistsTrue.
@Test
public void testDropCacheNotExistsTrue() {
QualifiedName tableName = QualifiedName.of(CATALOG_NAME, schema, table);
DropCache statement = new DropCache(tableName, true);
getFutureValue(new DropCacheTask().execute(statement, createTestTransactionManager(), metadata, new AllowAllAccessControl(), stateMachine, Collections.emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
assertFalse(SplitCacheMap.getInstance().cacheExists(tableName));
QualifiedName table2Name = QualifiedName.of(CATALOG_NAME, schema, table2);
DropCache statement2 = new DropCache(table2Name, true);
assertTrue(SplitCacheMap.getInstance().cacheExists(table2Name));
getFutureValue(new DropCacheTask().execute(statement2, createTestTransactionManager(), metadata, new AllowAllAccessControl(), stateMachine, Collections.emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
assertFalse(SplitCacheMap.getInstance().cacheExists(table2Name));
}
use of io.prestosql.sql.tree.DropCache in project hetu-core by openlookeng.
the class TestDropCacheTask method testDropCacheNotExistsFalse.
@Test
public void testDropCacheNotExistsFalse() {
DropCache statement = new DropCache(QualifiedName.of("test_nonexistent_table"), false);
QueryStateMachine queryStateMachine = createQueryStateMachine("START TRANSACTION", testSession, transactionManager);
try {
getFutureValue(new DropCacheTask().execute(statement, createTestTransactionManager(), metadata, new AllowAllAccessControl(), queryStateMachine, Collections.emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
fail("expected exception");
} catch (RuntimeException e) {
// Expected
assertTrue(e instanceof SemanticException);
SemanticException semanticException = (SemanticException) e;
assertEquals(semanticException.getCode(), SemanticErrorCode.MISSING_CACHE);
}
}
Aggregations