use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateTableTask method testCreateLikeWithProperties.
@Test
public void testCreateLikeWithProperties() {
CreateTable statement = getCreatleLikeStatement(true);
CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
getFutureValue(createTableTask.internalExecute(statement, testSession, List.of(), output -> {
}));
assertEquals(metadata.getCreateTableCallCount(), 1);
assertThat(metadata.getReceivedTableMetadata().get(0).getColumns()).isEqualTo(PARENT_TABLE.getColumns());
assertThat(metadata.getReceivedTableMetadata().get(0).getProperties()).isEqualTo(PARENT_TABLE.getProperties());
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateTableTask method testCreateTableNotExistsFalse.
@Test
public void testCreateTableNotExistsFalse() {
CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), toSqlType(BIGINT), true, emptyList(), Optional.empty())), false, ImmutableList.of(), Optional.empty());
CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
assertTrinoExceptionThrownBy(() -> getFutureValue(createTableTask.internalExecute(statement, testSession, emptyList(), output -> {
}))).hasErrorCode(ALREADY_EXISTS).hasMessage("Table already exists");
assertEquals(metadata.getCreateTableCallCount(), 1);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateTableTask method testCreateTableWithMaterializedViewPropertyFails.
@Test
public void testCreateTableWithMaterializedViewPropertyFails() {
CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), toSqlType(BIGINT), true, emptyList(), Optional.empty())), false, ImmutableList.of(new Property(new Identifier("foo"), new StringLiteral("bar"))), Optional.empty());
CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
assertTrinoExceptionThrownBy(() -> getFutureValue(createTableTask.internalExecute(statement, testSession, emptyList(), output -> {
}))).hasErrorCode(INVALID_TABLE_PROPERTY).hasMessage("Catalog 'catalog' table property 'foo' does not exist");
assertEquals(metadata.getCreateTableCallCount(), 0);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateTableTask method testCreateTableNotExistsTrue.
@Test
public void testCreateTableNotExistsTrue() {
CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), toSqlType(BIGINT), true, emptyList(), Optional.empty())), true, ImmutableList.of(), Optional.empty());
CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
getFutureValue(createTableTask.internalExecute(statement, testSession, emptyList(), output -> {
}));
assertEquals(metadata.getCreateTableCallCount(), 1);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateTableTask method testCreateWithUnsupportedConnectorThrowsWhenNotNull.
@Test
public void testCreateWithUnsupportedConnectorThrowsWhenNotNull() {
List<TableElement> inputColumns = ImmutableList.of(new ColumnDefinition(identifier("a"), toSqlType(DATE), true, emptyList(), Optional.empty()), new ColumnDefinition(identifier("b"), toSqlType(VARCHAR), false, emptyList(), Optional.empty()), new ColumnDefinition(identifier("c"), toSqlType(VARBINARY), false, emptyList(), Optional.empty()));
CreateTable statement = new CreateTable(QualifiedName.of("test_table"), inputColumns, true, ImmutableList.of(), Optional.empty());
CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
assertTrinoExceptionThrownBy(() -> getFutureValue(createTableTask.internalExecute(statement, testSession, emptyList(), output -> {
}))).hasErrorCode(NOT_SUPPORTED).hasMessage("Catalog 'catalog' does not support non-null column for column name 'b'");
}
Aggregations