use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateMaterializedViewTask method testCreateMaterializedViewWithExistingView.
@Test
public void testCreateMaterializedViewWithExistingView() {
CreateMaterializedView statement = new CreateMaterializedView(Optional.empty(), QualifiedName.of("test_mv"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("catalog", "schema", "mock_table"))), false, false, ImmutableList.of(), Optional.empty());
assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(plannerContext, new AllowAllAccessControl(), parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))).hasErrorCode(ALREADY_EXISTS).hasMessage("Materialized view already exists");
assertEquals(metadata.getCreateMaterializedViewCallCount(), 1);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateMaterializedViewTask method testCreateMaterializedViewWithDefaultProperties.
@Test
public void testCreateMaterializedViewWithDefaultProperties() {
QualifiedName materializedViewName = QualifiedName.of("catalog", "schema", "mv");
CreateMaterializedView statement = new CreateMaterializedView(Optional.empty(), materializedViewName, simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("catalog", "schema", "mock_table"))), false, true, ImmutableList.of(// set foo to DEFAULT
new Property(new Identifier("foo")), // set bar to DEFAULT
new Property(new Identifier("bar"))), Optional.empty());
getFutureValue(new CreateMaterializedViewTask(plannerContext, new AllowAllAccessControl(), parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP));
Optional<MaterializedViewDefinition> definitionOptional = metadata.getMaterializedView(testSession, QualifiedObjectName.valueOf(materializedViewName.toString()));
assertThat(definitionOptional).isPresent();
Map<String, Object> properties = definitionOptional.get().getProperties();
assertThat(properties.get("foo")).isEqualTo(DEFAULT_MATERIALIZED_VIEW_FOO_PROPERTY_VALUE);
assertThat(properties.get("bar")).isEqualTo(DEFAULT_MATERIALIZED_VIEW_BAR_PROPERTY_VALUE);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateMaterializedViewTask method setUp.
@BeforeMethod
public void setUp() {
queryRunner = LocalQueryRunner.create(TEST_SESSION);
transactionManager = queryRunner.getTransactionManager();
queryRunner.createCatalog(CATALOG_NAME, MockConnectorFactory.builder().withGetMaterializedViewProperties(() -> ImmutableList.<PropertyMetadata<?>>builder().add(stringProperty("foo", "test materialized view property", DEFAULT_MATERIALIZED_VIEW_FOO_PROPERTY_VALUE, false)).add(integerProperty("bar", "test materialized view property", DEFAULT_MATERIALIZED_VIEW_BAR_PROPERTY_VALUE, false)).build()).build(), ImmutableMap.of());
materializedViewPropertyManager = queryRunner.getMaterializedViewPropertyManager();
testSession = testSessionBuilder().build();
metadata = new MockMetadata(new CatalogName(CATALOG_NAME));
plannerContext = plannerContextBuilder().withMetadata(metadata).build();
parser = queryRunner.getSqlParser();
analyzerFactory = new AnalyzerFactory(createTestingStatementAnalyzerFactory(plannerContext, new AllowAllAccessControl(), new TablePropertyManager(), new AnalyzePropertyManager()), new StatementRewrite(ImmutableSet.of()));
queryStateMachine = stateMachine(transactionManager, createTestMetadataManager(), new AllowAllAccessControl());
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateMaterializedViewTask method testCreateMaterializedViewWithInvalidProperty.
@Test
public void testCreateMaterializedViewWithInvalidProperty() {
CreateMaterializedView statement = new CreateMaterializedView(Optional.empty(), QualifiedName.of("test_mv"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("catalog", "schema", "mock_table"))), false, true, ImmutableList.of(new Property(new Identifier("baz"), new StringLiteral("abc"))), Optional.empty());
assertTrinoExceptionThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(plannerContext, new AllowAllAccessControl(), parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))).hasErrorCode(INVALID_MATERIALIZED_VIEW_PROPERTY).hasMessage("Catalog 'catalog' materialized view property 'baz' does not exist");
assertEquals(metadata.getCreateMaterializedViewCallCount(), 0);
}
use of io.trino.security.AllowAllAccessControl in project trino by trinodb.
the class TestCreateSchemaTask method getCreateSchemaTask.
private CreateSchemaTask getCreateSchemaTask() {
SchemaPropertyManager schemaPropertyManager = new SchemaPropertyManager();
schemaPropertyManager.addProperties(new CatalogName(CATALOG_NAME), ImmutableList.of());
return new CreateSchemaTask(plannerContext, new AllowAllAccessControl(), schemaPropertyManager);
}
Aggregations