Search in sources :

Example 21 with ConnectorSession

use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.

the class MetadataManager method applySample.

@Override
public Optional<TableHandle> applySample(Session session, TableHandle table, SampleType sampleType, double sampleRatio) {
    CatalogName catalogName = table.getCatalogName();
    ConnectorMetadata metadata = getMetadata(session, catalogName);
    if (metadata.usesLegacyTableLayouts()) {
        return Optional.empty();
    }
    ConnectorSession connectorSession = session.toConnectorSession(catalogName);
    return metadata.applySample(connectorSession, table.getConnectorHandle(), sampleType, sampleRatio).map(result -> new TableHandle(catalogName, result, table.getTransaction(), Optional.empty()));
}
Also used : CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorVacuumTableHandle(io.prestosql.spi.connector.ConnectorVacuumTableHandle) ConnectorDeleteAsInsertTableHandle(io.prestosql.spi.connector.ConnectorDeleteAsInsertTableHandle) ConnectorUpdateTableHandle(io.prestosql.spi.connector.ConnectorUpdateTableHandle) ConnectorOutputTableHandle(io.prestosql.spi.connector.ConnectorOutputTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle) ConnectorInsertTableHandle(io.prestosql.spi.connector.ConnectorInsertTableHandle) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Example 22 with ConnectorSession

use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.

the class MetadataManager method listEnabledRoles.

@Override
public Set<String> listEnabledRoles(Session session, String catalog) {
    Optional<CatalogMetadata> catalogMetadata = getOptionalCatalogMetadata(session, catalog);
    if (!catalogMetadata.isPresent()) {
        return ImmutableSet.of();
    }
    CatalogName catalogName = catalogMetadata.get().getCatalogName();
    ConnectorSession connectorSession = session.toConnectorSession(catalogName);
    ConnectorMetadata metadata = catalogMetadata.get().getMetadataFor(catalogName);
    return ImmutableSet.copyOf(metadata.listEnabledRoles(connectorSession));
}
Also used : CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Example 23 with ConnectorSession

use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.

the class MetadataManager method getNewTableLayout.

@Override
public Optional<NewTableLayout> getNewTableLayout(Session session, String catalogName, ConnectorTableMetadata tableMetadata) {
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
    CatalogName catalog = catalogMetadata.getCatalogName();
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    ConnectorTransactionHandle transactionHandle = catalogMetadata.getTransactionHandleFor(catalog);
    ConnectorSession connectorSession = session.toConnectorSession(catalog);
    return metadata.getNewTableLayout(connectorSession, tableMetadata).map(layout -> new NewTableLayout(catalog, transactionHandle, layout));
}
Also used : ConnectorTransactionHandle(io.prestosql.spi.connector.ConnectorTransactionHandle) CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Example 24 with ConnectorSession

use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.

the class MetadataManager method listRoles.

@Override
public Set<String> listRoles(Session session, String catalog) {
    Optional<CatalogMetadata> catalogMetadata = getOptionalCatalogMetadata(session, catalog);
    if (!catalogMetadata.isPresent()) {
        return ImmutableSet.of();
    }
    CatalogName catalogName = catalogMetadata.get().getCatalogName();
    ConnectorSession connectorSession = session.toConnectorSession(catalogName);
    ConnectorMetadata metadata = catalogMetadata.get().getMetadataFor(catalogName);
    return metadata.listRoles(connectorSession).stream().collect(toImmutableSet());
}
Also used : CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Example 25 with ConnectorSession

use of io.prestosql.spi.connector.ConnectorSession in project hetu-core by openlookeng.

the class MetadataManager method getTableHandle.

@Override
public Optional<TableHandle> getTableHandle(Session session, QualifiedObjectName table) {
    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(catalogName);
        ConnectorSession connectorSession = session.toConnectorSession(catalogName);
        ConnectorTableHandle tableHandle = metadata.getTableHandle(connectorSession, toSchemaTableName(table));
        if (tableHandle != null) {
            return Optional.of(new TableHandle(catalogName, tableHandle, catalogMetadata.getTransactionHandleFor(catalogName), Optional.empty()));
        }
    }
    return Optional.empty();
}
Also used : CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorVacuumTableHandle(io.prestosql.spi.connector.ConnectorVacuumTableHandle) ConnectorDeleteAsInsertTableHandle(io.prestosql.spi.connector.ConnectorDeleteAsInsertTableHandle) ConnectorUpdateTableHandle(io.prestosql.spi.connector.ConnectorUpdateTableHandle) ConnectorOutputTableHandle(io.prestosql.spi.connector.ConnectorOutputTableHandle) TableHandle(io.prestosql.spi.metadata.TableHandle) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle) ConnectorInsertTableHandle(io.prestosql.spi.connector.ConnectorInsertTableHandle) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle)

Aggregations

ConnectorSession (io.prestosql.spi.connector.ConnectorSession)267 TestingConnectorSession (io.prestosql.testing.TestingConnectorSession)160 ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)159 ConnectorTableHandle (io.prestosql.spi.connector.ConnectorTableHandle)130 Test (org.testng.annotations.Test)115 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)107 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)98 ColumnMetadata (io.prestosql.spi.connector.ColumnMetadata)90 PrestoException (io.prestosql.spi.PrestoException)83 TupleDomain (io.prestosql.spi.predicate.TupleDomain)83 List (java.util.List)82 ImmutableList (com.google.common.collect.ImmutableList)80 ConnectorTableMetadata (io.prestosql.spi.connector.ConnectorTableMetadata)79 Optional (java.util.Optional)78 Objects.requireNonNull (java.util.Objects.requireNonNull)74 Path (org.apache.hadoop.fs.Path)74 Slice (io.airlift.slice.Slice)72 ImmutableMap (com.google.common.collect.ImmutableMap)67 HiveIdentity (io.prestosql.plugin.hive.authentication.HiveIdentity)65 ConnectorInsertTableHandle (io.prestosql.spi.connector.ConnectorInsertTableHandle)65