use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.
the class TestFileBasedSystemAccessControl method testTableRulesForCheckCanGrantTablePrivilege.
@Test
public void testTableRulesForCheckCanGrantTablePrivilege() {
SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-access-table.json");
accessControl.checkCanGrantTablePrivilege(ADMIN, Privilege.DELETE, new CatalogSchemaTableName("some-catalog", "bobschema", "bobtable"), null, false);
assertAccessDenied(() -> accessControl.checkCanGrantTablePrivilege(BOB, Privilege.DELETE, new CatalogSchemaTableName("some-catalog", "bobschema", "bobtable"), null, false), GRANT_DELETE_PRIVILEGE_ACCESS_DENIED_MESSAGE);
}
use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.
the class TestFileBasedSystemAccessControl method testTableRulesForCheckCanDropMaterializedView.
@Test
public void testTableRulesForCheckCanDropMaterializedView() {
SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-access-table.json");
accessControl.checkCanDropMaterializedView(ADMIN, new CatalogSchemaTableName("some-catalog", "bobschema", "bob-materialized-view"));
assertAccessDenied(() -> accessControl.checkCanDropMaterializedView(BOB, new CatalogSchemaTableName("some-catalog", "bobschema", "bob-materialized-view")), DROP_MATERIALIZED_VIEW_ACCESS_DENIED_MESSAGE);
}
use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.
the class TestFileBasedSystemAccessControl method testTableRulesForFilterColumnsWithNoAccess.
@Test
public void testTableRulesForFilterColumnsWithNoAccess() {
SystemAccessControl accessControl = newFileBasedSystemAccessControl("file-based-system-no-access.json");
assertEquals(accessControl.filterColumns(BOB, new CatalogSchemaTableName("some-catalog", "bobschema", "bobtable"), ImmutableSet.of("a")), ImmutableSet.of());
}
use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.
the class ViewReaderUtil method coralTableRedirectionResolver.
private static CoralTableRedirectionResolver coralTableRedirectionResolver(ConnectorSession session, BiFunction<ConnectorSession, SchemaTableName, Optional<CatalogSchemaTableName>> tableRedirectionResolver, MetadataProvider metadataProvider) {
return schemaTableName -> tableRedirectionResolver.apply(session, schemaTableName).map(target -> {
ConnectorTableSchema tableSchema = metadataProvider.getRelationMetadata(session, target).orElseThrow(() -> new TableNotFoundException(target.getSchemaTableName(), format("%s is redirected to %s, but that relation cannot be found", schemaTableName, target)));
List<Column> columns = tableSchema.getColumns().stream().filter(columnSchema -> !columnSchema.isHidden()).map(columnSchema -> new Column(columnSchema.getName(), toHiveType(columnSchema.getType()), Optional.empty())).collect(toImmutableList());
Table table = Table.builder().setDatabaseName(schemaTableName.getSchemaName()).setTableName(schemaTableName.getTableName()).setTableType(EXTERNAL_TABLE.name()).setDataColumns(columns).withStorage(storage -> storage.setStorageFormat(fromHiveStorageFormat(TEXTFILE))).setOwner(Optional.empty()).build();
return toMetastoreApiTable(table);
});
}
use of io.trino.spi.connector.CatalogSchemaTableName in project trino by trinodb.
the class MetadataManager method renameTable.
@Override
public void renameTable(Session session, TableHandle tableHandle, QualifiedObjectName newTableName) {
String catalogName = newTableName.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
CatalogName catalog = catalogMetadata.getCatalogName();
if (!tableHandle.getCatalogName().equals(catalog)) {
throw new TrinoException(SYNTAX_ERROR, "Cannot rename tables across catalogs");
}
Optional<CatalogSchemaTableName> sourceTableName = getTableNameIfSystemSecurity(session, catalogMetadata, tableHandle);
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
metadata.renameTable(session.toConnectorSession(catalog), tableHandle.getConnectorHandle(), newTableName.asSchemaTableName());
sourceTableName.ifPresent(name -> systemSecurityMetadata.tableRenamed(session, name, newTableName.asCatalogSchemaTableName()));
}
Aggregations