Search in sources :

Example 21 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 22 with AllowAllAccessControl

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

the class TestCreateMaterializedViewTask method setUp.

@BeforeMethod
public void setUp() {
    CatalogManager catalogManager = new CatalogManager();
    Catalog testCatalog = createBogusTestingCatalog(CATALOG_NAME);
    catalogManager.registerCatalog(testCatalog);
    TablePropertyManager tablePropertyManager = new TablePropertyManager();
    tablePropertyManager.addProperties(testCatalog.getConnectorId(), ImmutableList.of(stringProperty("baz", "test property", null, false)));
    ColumnPropertyManager columnPropertyManager = new ColumnPropertyManager();
    columnPropertyManager.addProperties(testCatalog.getConnectorId(), ImmutableList.of());
    FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
    transactionManager = createTestTransactionManager(catalogManager);
    testSession = testSessionBuilder().setTransactionId(transactionManager.beginTransaction(false)).build();
    accessControl = new AllowAllAccessControl();
    executorService = newCachedThreadPool(daemonThreadsNamed("test-%s"));
    metadata = new MockMetadata(functionAndTypeManager, tablePropertyManager, columnPropertyManager, testCatalog.getConnectorId());
}
Also used : ColumnPropertyManager(com.facebook.presto.metadata.ColumnPropertyManager) FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) FunctionAndTypeManager.createTestFunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) AbstractMockMetadata(com.facebook.presto.metadata.AbstractMockMetadata) TablePropertyManager(com.facebook.presto.metadata.TablePropertyManager) CatalogManager(com.facebook.presto.metadata.CatalogManager) Catalog(com.facebook.presto.metadata.Catalog) TestingSession.createBogusTestingCatalog(com.facebook.presto.testing.TestingSession.createBogusTestingCatalog) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 23 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 24 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 25 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)

Aggregations

AllowAllAccessControl (com.facebook.presto.security.AllowAllAccessControl)64 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)33 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 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)8 TableHandle (com.facebook.presto.spi.TableHandle)8 WarningCollector (com.facebook.presto.spi.WarningCollector)8 ColumnDefinition (com.facebook.presto.sql.tree.ColumnDefinition)8 CreateTable (com.facebook.presto.sql.tree.CreateTable)8 CatalogManager (com.facebook.presto.metadata.CatalogManager)6 Identifier (com.facebook.presto.sql.tree.Identifier)6 Rollback (com.facebook.presto.sql.tree.Rollback)6 SessionPropertyManager (com.facebook.presto.metadata.SessionPropertyManager)5 QueryId (com.facebook.presto.spi.QueryId)5