Search in sources :

Example 1 with DropFunction

use of com.facebook.presto.sql.tree.DropFunction in project presto by prestodb.

the class TestDropFunctionTask method executeAndGetRemovedSessionFunctions.

private Set<SqlFunctionId> executeAndGetRemovedSessionFunctions(String sqlString, Session session) {
    SqlParser parser = new SqlParser();
    DropFunction statement = (DropFunction) parser.createStatement(sqlString, ParsingOptions.builder().build());
    TransactionManager tm = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine(sqlString, session, false, tm, executorService, metadataManager);
    WarningCollector warningCollector = stateMachine.getWarningCollector();
    DropFunctionTask dropFunctionTask = new DropFunctionTask(parser);
    dropFunctionTask.execute(statement, tm, metadataManager, new AllowAllAccessControl(), session, emptyList(), warningCollector);
    return dropFunctionTask.getRemovedSessionFunctions();
}
Also used : TaskTestUtils.createQueryStateMachine(com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine) TransactionManager(com.facebook.presto.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(com.facebook.presto.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) SqlParser(com.facebook.presto.sql.parser.SqlParser) WarningCollector(com.facebook.presto.spi.WarningCollector) DropFunction(com.facebook.presto.sql.tree.DropFunction)

Example 2 with DropFunction

use of com.facebook.presto.sql.tree.DropFunction in project presto by prestodb.

the class TestSqlParser method testDropFunction.

@Test
public void testDropFunction() {
    assertStatement("DROP FUNCTION a", new DropFunction(QualifiedName.of("a"), Optional.empty(), false, false));
    assertStatement("DROP FUNCTION a.b", new DropFunction(QualifiedName.of("a", "b"), Optional.empty(), false, false));
    assertStatement("DROP FUNCTION a.b.c", new DropFunction(QualifiedName.of("a", "b", "c"), Optional.empty(), false, false));
    assertStatement("DROP FUNCTION a()", new DropFunction(QualifiedName.of("a"), Optional.of(ImmutableList.of()), false, false));
    assertStatement("DROP FUNCTION a.b()", new DropFunction(QualifiedName.of("a", "b"), Optional.of(ImmutableList.of()), false, false));
    assertStatement("DROP FUNCTION a.b.c()", new DropFunction(QualifiedName.of("a", "b", "c"), Optional.of(ImmutableList.of()), false, false));
    assertStatement("DROP FUNCTION IF EXISTS a.b.c(int)", new DropFunction(QualifiedName.of("a", "b", "c"), Optional.of(ImmutableList.of("int")), false, true));
    assertStatement("DROP FUNCTION IF EXISTS a.b.c(bigint, double)", new DropFunction(QualifiedName.of("a", "b", "c"), Optional.of(ImmutableList.of("bigint", "double")), false, true));
    assertStatement("DROP FUNCTION IF EXISTS a.b.c(ARRAY(string), MAP(int,double))", new DropFunction(QualifiedName.of("a", "b", "c"), Optional.of(ImmutableList.of("ARRAY(string)", "MAP(int,double)")), false, true));
}
Also used : DropFunction(com.facebook.presto.sql.tree.DropFunction) Test(org.testng.annotations.Test)

Aggregations

DropFunction (com.facebook.presto.sql.tree.DropFunction)2 TaskTestUtils.createQueryStateMachine (com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine)1 AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)1 WarningCollector (com.facebook.presto.spi.WarningCollector)1 SqlParser (com.facebook.presto.sql.parser.SqlParser)1 InMemoryTransactionManager.createTestTransactionManager (com.facebook.presto.transaction.InMemoryTransactionManager.createTestTransactionManager)1 TransactionManager (com.facebook.presto.transaction.TransactionManager)1 Test (org.testng.annotations.Test)1