use of io.trino.metadata.TablePropertyManager in project trino by trinodb.
the class TestCreateMaterializedViewTask method testCreateDenyPermission.
@Test
public void testCreateDenyPermission() {
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(), Optional.empty());
TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, emptyEventListenerManager());
accessControl.loadSystemAccessControl(AllowAllSystemAccessControl.NAME, ImmutableMap.of());
accessControl.deny(privilege("test_mv", CREATE_MATERIALIZED_VIEW));
StatementAnalyzerFactory statementAnalyzerFactory = createTestingStatementAnalyzerFactory(plannerContext, accessControl, new TablePropertyManager(), new AnalyzePropertyManager());
AnalyzerFactory analyzerFactory = new AnalyzerFactory(statementAnalyzerFactory, new StatementRewrite(ImmutableSet.of()));
assertThatThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(plannerContext, accessControl, parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))).isInstanceOf(AccessDeniedException.class).hasMessageContaining("Cannot create materialized view catalog.schema.test_mv");
}
use of io.trino.metadata.TablePropertyManager in project trino by trinodb.
the class TestCreateTableTask method testCreateWithNotNullColumns.
@Test
public void testCreateWithNotNullColumns() {
metadata.setConnectorCapabilities(NOT_NULL_COLUMN_CONSTRAINT);
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);
getFutureValue(createTableTask.internalExecute(statement, testSession, emptyList(), output -> {
}));
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());
}
use of io.trino.metadata.TablePropertyManager in project trino by trinodb.
the class TestCreateTableTask method testCreateLike.
@Test
public void testCreateLike() {
CreateTable statement = getCreatleLikeStatement(false);
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()).isEmpty();
}
use of io.trino.metadata.TablePropertyManager in project trino by trinodb.
the class TestCreateViewTask method setUp.
@Override
@BeforeMethod
public void setUp() {
super.setUp();
parser = new SqlParser();
analyzerFactory = new AnalyzerFactory(createTestingStatementAnalyzerFactory(plannerContext, new AllowAllAccessControl(), new TablePropertyManager(), new AnalyzePropertyManager()), new StatementRewrite(ImmutableSet.of()));
QualifiedObjectName tableName = qualifiedObjectName("mock_table");
metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
}
use of io.trino.metadata.TablePropertyManager 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());
}
Aggregations