use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestRenameMaterializedViewTask method testRenameMaterializedViewTargetTableExists.
@Test
public void testRenameMaterializedViewTargetTableExists() {
QualifiedObjectName materializedViewName = qualifiedObjectName("existing_materialized_view");
metadata.createMaterializedView(testSession, materializedViewName, someMaterializedView(), false, false);
QualifiedObjectName tableName = qualifiedObjectName("existing_table");
metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameMaterializedView(asQualifiedName(materializedViewName), asQualifiedName(tableName)))).hasErrorCode(TABLE_ALREADY_EXISTS).hasMessage("Target materialized view '%s' does not exist, but a table with that name exists.", tableName);
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestRenameTableTask method testRenameTableOnViewIfExists.
@Test
public void testRenameTableOnViewIfExists() {
QualifiedObjectName viewName = qualifiedObjectName("existing_view");
metadata.createView(testSession, viewName, someView(), false);
getFutureValue(executeRenameTable(asQualifiedName(viewName), qualifiedName("existing_view_new"), true));
// no exception
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestRenameTableTask method testRenameTableOnView.
@Test
public void testRenameTableOnView() {
QualifiedObjectName viewName = qualifiedObjectName("existing_view");
metadata.createView(testSession, viewName, someView(), false);
assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameTable(asQualifiedName(viewName), qualifiedName("existing_view_new"), false))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("Table '%s' does not exist, but a view with that name exists. Did you mean ALTER VIEW %s RENAME ...?", viewName, viewName);
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestAccessControlManager method testDenyCatalogAccessControl.
@Test
public void testDenyCatalogAccessControl() {
try (LocalQueryRunner queryRunner = LocalQueryRunner.create(TEST_SESSION)) {
TransactionManager transactionManager = queryRunner.getTransactionManager();
AccessControlManager accessControlManager = createAccessControlManager(transactionManager);
TestSystemAccessControlFactory accessControlFactory = new TestSystemAccessControlFactory("test");
accessControlManager.addSystemAccessControlFactory(accessControlFactory);
accessControlManager.setSystemAccessControl("test", ImmutableMap.of());
queryRunner.createCatalog("catalog", MockConnectorFactory.create(), ImmutableMap.of());
accessControlManager.addCatalogAccessControl(new CatalogName("catalog"), new DenyConnectorAccessControl());
assertThatThrownBy(() -> transaction(transactionManager, accessControlManager).execute(transactionId -> {
accessControlManager.checkCanSelectFromColumns(context(transactionId), new QualifiedObjectName("catalog", "schema", "table"), ImmutableSet.of("column"));
})).isInstanceOf(TrinoException.class).hasMessageMatching("Access Denied: Cannot select from columns \\[column\\] in table or view schema.table");
}
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestAccessControlManager method testNoCatalogAccessControl.
@Test
public void testNoCatalogAccessControl() {
TransactionManager transactionManager = createTestTransactionManager();
AccessControlManager accessControlManager = createAccessControlManager(transactionManager);
TestSystemAccessControlFactory accessControlFactory = new TestSystemAccessControlFactory("test");
accessControlManager.addSystemAccessControlFactory(accessControlFactory);
accessControlManager.setSystemAccessControl("test", ImmutableMap.of());
transaction(transactionManager, accessControlManager).execute(transactionId -> {
accessControlManager.checkCanSelectFromColumns(context(transactionId), new QualifiedObjectName("catalog", "schema", "table"), ImmutableSet.of("column"));
});
}
Aggregations