Search in sources :

Example 26 with AllowAllAccessControl

use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.

the class TestCreateFunctionTask method testCreateTemporaryFunctionWithSameNameFails.

@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = "Session function .* has already been defined")
public void testCreateTemporaryFunctionWithSameNameFails() {
    SqlParser parser = new SqlParser();
    String sqlString = "CREATE TEMPORARY FUNCTION foo() RETURNS int RETURN 1";
    CreateFunction statement = (CreateFunction) parser.createStatement(sqlString, ParsingOptions.builder().build());
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine(sqlString, TEST_SESSION, false, transactionManager, executorService, metadataManager);
    WarningCollector warningCollector = stateMachine.getWarningCollector();
    CreateFunctionTask createFunctionTask = new CreateFunctionTask(parser);
    createFunctionTask.execute(statement, transactionManager, metadataManager, new AllowAllAccessControl(), TEST_SESSION, emptyList(), warningCollector);
    createFunctionTask.execute(statement, transactionManager, metadataManager, new AllowAllAccessControl(), TEST_SESSION, emptyList(), warningCollector);
}
Also used : TaskTestUtils.createQueryStateMachine(com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine) InMemoryTransactionManager.createTestTransactionManager(com.facebook.presto.transaction.InMemoryTransactionManager.createTestTransactionManager) TransactionManager(com.facebook.presto.transaction.TransactionManager) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) CreateFunction(com.facebook.presto.sql.tree.CreateFunction) SqlParser(com.facebook.presto.sql.parser.SqlParser) WarningCollector(com.facebook.presto.spi.WarningCollector) Test(org.testng.annotations.Test)

Example 27 with AllowAllAccessControl

use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.

the class TestCreateTableTask method testCreateWithUnsupportedConnectorThrowsWhenNotNull.

@Test(expectedExceptions = SemanticException.class, expectedExceptionsMessageRegExp = ".*does not support non-null column for column name 'b'")
public void testCreateWithUnsupportedConnectorThrowsWhenNotNull() {
    List<TableElement> inputColumns = ImmutableList.of(new ColumnDefinition(identifier("a"), "DATE", true, emptyList(), Optional.empty()), new ColumnDefinition(identifier("b"), "VARCHAR", false, emptyList(), Optional.empty()), new ColumnDefinition(identifier("c"), "VARBINARY", false, emptyList(), Optional.empty()));
    CreateTable statement = new CreateTable(QualifiedName.of("test_table"), inputColumns, true, ImmutableList.of(), Optional.empty());
    getFutureValue(new CreateTableTask().internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList()));
}
Also used : AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) CreateTable(com.facebook.presto.sql.tree.CreateTable) TableElement(com.facebook.presto.sql.tree.TableElement) ColumnDefinition(com.facebook.presto.sql.tree.ColumnDefinition) Test(org.testng.annotations.Test)

Example 28 with AllowAllAccessControl

use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.

the class TestCreateTableTask method testCreateWithNotNullColumns.

@Test
public void testCreateWithNotNullColumns() {
    metadata.setConnectorCapabilities(NOT_NULL_COLUMN_CONSTRAINT);
    List<TableElement> inputColumns = ImmutableList.of(new ColumnDefinition(identifier("a"), "DATE", true, emptyList(), Optional.empty()), new ColumnDefinition(identifier("b"), "VARCHAR", false, emptyList(), Optional.empty()), new ColumnDefinition(identifier("c"), "VARBINARY", false, emptyList(), Optional.empty()));
    CreateTable statement = new CreateTable(QualifiedName.of("test_table"), inputColumns, true, ImmutableList.of(), Optional.empty());
    getFutureValue(new CreateTableTask().internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList()));
    assertEquals(metadata.getCreateTableCallCount(), 1);
    List<ColumnMetadata> columns = metadata.getReceivedTableMetadata().get(0).getColumns();
    assertEquals(columns.size(), 3);
    assertEquals(columns.get(0).getName(), "a");
    assertEquals(columns.get(0).getType().getDisplayName().toUpperCase(ENGLISH), "DATE");
    assertTrue(columns.get(0).isNullable());
    assertEquals(columns.get(1).getName(), "b");
    assertEquals(columns.get(1).getType().getDisplayName().toUpperCase(ENGLISH), "VARCHAR");
    assertFalse(columns.get(1).isNullable());
    assertEquals(columns.get(2).getName(), "c");
    assertEquals(columns.get(2).getType().getDisplayName().toUpperCase(ENGLISH), "VARBINARY");
    assertFalse(columns.get(2).isNullable());
}
Also used : ColumnMetadata(com.facebook.presto.spi.ColumnMetadata) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) CreateTable(com.facebook.presto.sql.tree.CreateTable) TableElement(com.facebook.presto.sql.tree.TableElement) ColumnDefinition(com.facebook.presto.sql.tree.ColumnDefinition) Test(org.testng.annotations.Test)

Example 29 with AllowAllAccessControl

use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.

the class TestCreateTableTask method testCreateTableNotExistsTrue.

@Test
public void testCreateTableNotExistsTrue() {
    CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), "BIGINT", true, emptyList(), Optional.empty())), true, ImmutableList.of(), Optional.empty());
    getFutureValue(new CreateTableTask().internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList()));
    assertEquals(metadata.getCreateTableCallCount(), 1);
}
Also used : AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) CreateTable(com.facebook.presto.sql.tree.CreateTable) ColumnDefinition(com.facebook.presto.sql.tree.ColumnDefinition) Test(org.testng.annotations.Test)

Example 30 with AllowAllAccessControl

use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.

the class TestPrepareTask method executePrepare.

private Map<String, String> executePrepare(String statementName, Statement statement, String sqlString, Session session) {
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine(sqlString, session, false, transactionManager, executor, metadata);
    Prepare prepare = new Prepare(identifier(statementName), statement);
    PrepareTask prepareTask = new PrepareTask(new SqlParser());
    prepareTask.execute(prepare, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList());
    return stateMachine.getAddedPreparedStatements();
}
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) Prepare(com.facebook.presto.sql.tree.Prepare)

Aggregations

AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)62 Test (org.testng.annotations.Test)48 TaskTestUtils.createQueryStateMachine (com.facebook.presto.execution.TaskTestUtils.createQueryStateMachine)36 InMemoryTransactionManager.createTestTransactionManager (com.facebook.presto.transaction.InMemoryTransactionManager.createTestTransactionManager)36 TransactionManager (com.facebook.presto.transaction.TransactionManager)36 Session (com.facebook.presto.Session)31 StartTransaction (com.facebook.presto.sql.tree.StartTransaction)14 InMemoryTransactionManager (com.facebook.presto.transaction.InMemoryTransactionManager)14 PrestoException (com.facebook.presto.spi.PrestoException)12 SqlParser (com.facebook.presto.sql.parser.SqlParser)10 WarningCollector (com.facebook.presto.spi.WarningCollector)8 ColumnDefinition (com.facebook.presto.sql.tree.ColumnDefinition)8 CreateTable (com.facebook.presto.sql.tree.CreateTable)8 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)6 CatalogManager (com.facebook.presto.metadata.CatalogManager)6 TableHandle (com.facebook.presto.spi.TableHandle)6 Rollback (com.facebook.presto.sql.tree.Rollback)6 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)5 QueryId (com.facebook.presto.spi.QueryId)5 Commit (com.facebook.presto.sql.tree.Commit)5