Search in sources :

Example 1 with DropCache

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));
}
Also used : DropCache(io.prestosql.sql.tree.DropCache) Test(org.testng.annotations.Test)

Example 2 with DropCache

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));
}
Also used : DropCache(io.prestosql.sql.tree.DropCache) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) QualifiedName(io.prestosql.sql.tree.QualifiedName) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 3 with DropCache

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));
}
Also used : DropCache(io.prestosql.sql.tree.DropCache) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) QualifiedName(io.prestosql.sql.tree.QualifiedName) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 4 with DropCache

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);
    }
}
Also used : DropCache(io.prestosql.sql.tree.DropCache) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) SemanticException(io.prestosql.sql.analyzer.SemanticException) Test(org.testng.annotations.Test)

Aggregations

DropCache (io.prestosql.sql.tree.DropCache)4 Test (org.testng.annotations.Test)4 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)3 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)3 HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)3 AllowAllAccessControl (io.prestosql.security.AllowAllAccessControl)3 QualifiedName (io.prestosql.sql.tree.QualifiedName)2 Session (io.prestosql.Session)1 SemanticException (io.prestosql.sql.analyzer.SemanticException)1