use of io.trino.spi.connector.ConnectorTableHandle in project trino by trinodb.
the class MetadataManager method getTableHandle.
@Override
public Optional<TableHandle> getTableHandle(Session session, QualifiedObjectName table, Optional<TableVersion> startVersion, Optional<TableVersion> endVersion) {
requireNonNull(table, "table is null");
if (table.getCatalogName().isEmpty() || table.getSchemaName().isEmpty() || table.getObjectName().isEmpty()) {
// Table cannot exist
return Optional.empty();
}
return getOptionalCatalogMetadata(session, table.getCatalogName()).flatMap(catalogMetadata -> {
CatalogName catalogName = catalogMetadata.getConnectorId(session, table);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
// GetTableHandle with the optional version handle field will throw an error if it is not implemented, so only try calling it when we have a version
if (startVersion.isPresent() || endVersion.isPresent()) {
ConnectorTableHandle versionedTableHandle = metadata.getTableHandle(connectorSession, table.asSchemaTableName(), toConnectorVersion(startVersion), toConnectorVersion(endVersion));
return Optional.ofNullable(versionedTableHandle).map(connectorTableHandle -> new TableHandle(catalogName, connectorTableHandle, catalogMetadata.getTransactionHandleFor(catalogName)));
}
return Optional.ofNullable(metadata.getTableHandle(connectorSession, table.asSchemaTableName())).map(connectorTableHandle -> new TableHandle(catalogName, connectorTableHandle, catalogMetadata.getTransactionHandleFor(catalogName)));
});
}
use of io.trino.spi.connector.ConnectorTableHandle in project trino by trinodb.
the class MetadataManager method beginTableExecute.
@Override
public BeginTableExecuteResult<TableExecuteHandle, TableHandle> beginTableExecute(Session session, TableExecuteHandle tableExecuteHandle, TableHandle sourceHandle) {
CatalogName catalogName = tableExecuteHandle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
BeginTableExecuteResult<ConnectorTableExecuteHandle, ConnectorTableHandle> connectorBeginResult = metadata.beginTableExecute(session.toConnectorSession(), tableExecuteHandle.getConnectorHandle(), sourceHandle.getConnectorHandle());
return new BeginTableExecuteResult<>(tableExecuteHandle.withConnectorHandle(connectorBeginResult.getTableExecuteHandle()), sourceHandle.withConnectorHandle(connectorBeginResult.getSourceHandle()));
}
use of io.trino.spi.connector.ConnectorTableHandle in project trino by trinodb.
the class MetadataManager method getTableHandleForStatisticsCollection.
@Override
public Optional<TableHandle> getTableHandleForStatisticsCollection(Session session, QualifiedObjectName table, Map<String, Object> analyzeProperties) {
requireNonNull(table, "table is null");
Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, table.getCatalogName());
if (catalog.isPresent()) {
CatalogMetadata catalogMetadata = catalog.get();
CatalogName catalogName = catalogMetadata.getConnectorId(session, table);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(session, catalogName);
ConnectorTableHandle tableHandle = metadata.getTableHandleForStatisticsCollection(session.toConnectorSession(catalogName), table.asSchemaTableName(), analyzeProperties);
if (tableHandle != null) {
return Optional.of(new TableHandle(catalogName, tableHandle, catalogMetadata.getTransactionHandleFor(catalogName)));
}
}
return Optional.empty();
}
use of io.trino.spi.connector.ConnectorTableHandle in project trino by trinodb.
the class MetadataManager method beginStatisticsCollection.
@Override
public AnalyzeTableHandle beginStatisticsCollection(Session session, TableHandle tableHandle) {
CatalogName catalogName = tableHandle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadata(session);
ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalogName);
ConnectorTableHandle connectorTableHandle = metadata.beginStatisticsCollection(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
return new AnalyzeTableHandle(catalogName, transactionHandle, connectorTableHandle);
}
use of io.trino.spi.connector.ConnectorTableHandle in project trino by trinodb.
the class MetadataManager method beginDelete.
@Override
public TableHandle beginDelete(Session session, TableHandle tableHandle) {
CatalogName catalogName = tableHandle.getCatalogName();
ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
ConnectorTableHandle newHandle = metadata.beginDelete(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), getRetryPolicy(session).getRetryMode());
return new TableHandle(tableHandle.getCatalogName(), newHandle, tableHandle.getTransaction());
}
Aggregations