use of com.facebook.presto.connector.ConnectorId in project presto by prestodb.
the class MetadataManager method renameTable.
@Override
public void renameTable(Session session, TableHandle tableHandle, QualifiedObjectName newTableName) {
String catalogName = newTableName.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorId connectorId = catalogMetadata.getConnectorId();
if (!tableHandle.getConnectorId().equals(connectorId)) {
throw new PrestoException(SYNTAX_ERROR, "Cannot rename tables across catalogs");
}
ConnectorMetadata metadata = catalogMetadata.getMetadata();
metadata.renameTable(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(), newTableName.asSchemaTableName());
}
use of com.facebook.presto.connector.ConnectorId in project presto by prestodb.
the class MetadataManager method getNewTableLayout.
@Override
public Optional<NewTableLayout> getNewTableLayout(Session session, String catalogName, ConnectorTableMetadata tableMetadata) {
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorId connectorId = catalogMetadata.getConnectorId();
ConnectorMetadata metadata = catalogMetadata.getMetadata();
ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(connectorId);
ConnectorSession connectorSession = session.toConnectorSession(connectorId);
return metadata.getNewTableLayout(connectorSession, tableMetadata).map(layout -> new NewTableLayout(connectorId, transactionHandle, layout));
}
use of com.facebook.presto.connector.ConnectorId in project presto by prestodb.
the class MetadataManager method listSchemaNames.
@Override
public List<String> listSchemaNames(Session session, String catalogName) {
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, catalogName);
ImmutableSet.Builder<String> schemaNames = ImmutableSet.builder();
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
ConnectorSession connectorSession = session.toConnectorSession(catalogMetadata.getConnectorId());
for (ConnectorId connectorId : catalogMetadata.listConnectorIds()) {
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
schemaNames.addAll(metadata.listSchemaNames(connectorSession));
}
}
return ImmutableList.copyOf(schemaNames.build());
}
use of com.facebook.presto.connector.ConnectorId in project presto by prestodb.
the class MetadataManager method getUpdateRowIdColumnHandle.
@Override
public ColumnHandle getUpdateRowIdColumnHandle(Session session, TableHandle tableHandle) {
ConnectorId connectorId = tableHandle.getConnectorId();
ConnectorMetadata metadata = getMetadata(session, connectorId);
return metadata.getUpdateRowIdColumnHandle(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle());
}
use of com.facebook.presto.connector.ConnectorId in project presto by prestodb.
the class MetadataManager method renameColumn.
@Override
public void renameColumn(Session session, TableHandle tableHandle, ColumnHandle source, String target) {
ConnectorId connectorId = tableHandle.getConnectorId();
ConnectorMetadata metadata = getMetadataForWrite(session, connectorId);
metadata.renameColumn(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(), source, target.toLowerCase(ENGLISH));
}
Aggregations