Search in sources :

Example 16 with CatalogName

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

the class MetadataManager method getColumnMetadata.

@Override
public ColumnMetadata getColumnMetadata(Session session, TableHandle tableHandle, ColumnHandle columnHandle) {
    requireNonNull(tableHandle, "tableHandle is null");
    requireNonNull(columnHandle, "columnHandle is null");
    CatalogName catalogName = tableHandle.getCatalogName();
    ConnectorMetadata metadata = getMetadata(session, catalogName);
    return metadata.getColumnMetadata(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle(), columnHandle);
}
Also used : CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Example 17 with CatalogName

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

the class MetadataManager method listTablePrivileges.

@Override
public List<GrantInfo> listTablePrivileges(Session session, QualifiedTablePrefix prefix) {
    requireNonNull(prefix, "prefix is null");
    Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, prefix.getCatalogName());
    ImmutableSet.Builder<GrantInfo> grantInfos = ImmutableSet.builder();
    if (catalog.isPresent()) {
        CatalogMetadata catalogMetadata = catalog.get();
        ConnectorSession connectorSession = session.toConnectorSession(catalogMetadata.getCatalogName());
        List<CatalogName> connectorIds = prefix.asQualifiedObjectName().map(qualifiedTableName -> singletonList(catalogMetadata.getConnectorId(session, qualifiedTableName))).orElseGet(catalogMetadata::listConnectorIds);
        for (CatalogName catalogName : connectorIds) {
            ConnectorMetadata metadata = catalogMetadata.getMetadataFor(catalogName);
            grantInfos.addAll(metadata.listTablePrivileges(connectorSession, prefix.asSchemaTablePrefix()));
        }
    }
    return ImmutableList.copyOf(grantInfos.build());
}
Also used : TableStatistics(io.prestosql.spi.statistics.TableStatistics) PartialAndFinalAggregationType(io.prestosql.spi.PartialAndFinalAggregationType) LongSupplier(java.util.function.LongSupplier) RoleGrant(io.prestosql.spi.security.RoleGrant) ConnectorVacuumTableHandle(io.prestosql.spi.connector.ConnectorVacuumTableHandle) LimitApplicationResult(io.prestosql.spi.connector.LimitApplicationResult) LESS_THAN(io.prestosql.spi.function.OperatorType.LESS_THAN) Collections.singletonList(java.util.Collections.singletonList) ConnectorDeleteAsInsertTableHandle(io.prestosql.spi.connector.ConnectorDeleteAsInsertTableHandle) ConnectorUpdateTableHandle(io.prestosql.spi.connector.ConnectorUpdateTableHandle) Map(java.util.Map) ENGLISH(java.util.Locale.ENGLISH) ConnectorTableLayoutHandle(io.prestosql.spi.connector.ConnectorTableLayoutHandle) EQUAL(io.prestosql.spi.function.OperatorType.EQUAL) ConstraintApplicationResult(io.prestosql.spi.connector.ConstraintApplicationResult) SystemTable(io.prestosql.spi.connector.SystemTable) GrantInfo(io.prestosql.spi.security.GrantInfo) TableStatisticsMetadata(io.prestosql.spi.statistics.TableStatisticsMetadata) Set(java.util.Set) GuardedBy(javax.annotation.concurrent.GuardedBy) Privilege(io.prestosql.spi.security.Privilege) BETWEEN(io.prestosql.spi.function.OperatorType.BETWEEN) LESS_THAN_OR_EQUAL(io.prestosql.spi.function.OperatorType.LESS_THAN_OR_EQUAL) SchemaTablePrefix(io.prestosql.spi.connector.SchemaTablePrefix) Joiner(com.google.common.base.Joiner) Slice(io.airlift.slice.Slice) TypeSignatureProvider(io.prestosql.sql.analyzer.TypeSignatureProvider) TransactionManager(io.prestosql.transaction.TransactionManager) ProjectionApplicationResult(io.prestosql.spi.connector.ProjectionApplicationResult) TypeNotFoundException(io.prestosql.spi.type.TypeNotFoundException) ComputedStatistics(io.prestosql.spi.statistics.ComputedStatistics) QualifiedObjectName(io.prestosql.spi.connector.QualifiedObjectName) ArrayList(java.util.ArrayList) GREATER_THAN_OR_EQUAL(io.prestosql.spi.function.OperatorType.GREATER_THAN_OR_EQUAL) LinkedHashMap(java.util.LinkedHashMap) OptionalLong(java.util.OptionalLong) Session(io.prestosql.Session) ConnectorPartitioningHandle(io.prestosql.spi.connector.ConnectorPartitioningHandle) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) CatalogSchemaName(io.prestosql.spi.connector.CatalogSchemaName) LinkedHashSet(java.util.LinkedHashSet) ConnectorOutputTableHandle(io.prestosql.spi.connector.ConnectorOutputTableHandle) TypeSignatureProvider.fromTypes(io.prestosql.sql.analyzer.TypeSignatureProvider.fromTypes) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) MetadataUtil.toSchemaTableName(io.prestosql.metadata.MetadataUtil.toSchemaTableName) PartitioningHandle(io.prestosql.sql.planner.PartitioningHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) PrestoPrincipal(io.prestosql.spi.security.PrestoPrincipal) SYNTAX_ERROR(io.prestosql.spi.StandardErrorCode.SYNTAX_ERROR) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) DataCenterConnectorManager(io.prestosql.connector.DataCenterConnectorManager) Kryo(com.esotericsoftware.kryo.Kryo) MetadataUtil.convertFromSchemaTableName(io.prestosql.metadata.MetadataUtil.convertFromSchemaTableName) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) HashMultimap(com.google.common.collect.HashMultimap) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorTableProperties(io.prestosql.spi.connector.ConnectorTableProperties) Locale(java.util.Locale) OperatorType(io.prestosql.spi.function.OperatorType) Type(io.prestosql.spi.type.Type) SqlFunction(io.prestosql.spi.function.SqlFunction) ConnectorTableLayoutResult(io.prestosql.spi.connector.ConnectorTableLayoutResult) Constraint(io.prestosql.spi.connector.Constraint) PrestoException(io.prestosql.spi.PrestoException) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) Collection(java.util.Collection) CatalogName(io.prestosql.spi.connector.CatalogName) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConnectorResolvedIndex(io.prestosql.spi.connector.ConnectorResolvedIndex) SampleType(io.prestosql.spi.connector.SampleType) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) Entry(java.util.Map.Entry) ConnectorTransactionHandle(io.prestosql.spi.connector.ConnectorTransactionHandle) Optional(java.util.Optional) NOT_SUPPORTED(io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED) ConnectorExpression(io.prestosql.spi.expression.ConnectorExpression) TypeSignature(io.prestosql.spi.type.TypeSignature) HASH_CODE(io.prestosql.spi.function.OperatorType.HASH_CODE) ConnectorCapabilities(io.prestosql.spi.connector.ConnectorCapabilities) ConnectorOutputMetadata(io.prestosql.spi.connector.ConnectorOutputMetadata) NOT_EQUAL(io.prestosql.spi.function.OperatorType.NOT_EQUAL) ConnectorViewDefinition(io.prestosql.spi.connector.ConnectorViewDefinition) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) NOT_FOUND(io.prestosql.spi.StandardErrorCode.NOT_FOUND) TableHandle(io.prestosql.spi.metadata.TableHandle) ConcurrentMap(java.util.concurrent.ConcurrentMap) Inject(javax.inject.Inject) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ImmutableList(com.google.common.collect.ImmutableList) Verify.verify(com.google.common.base.Verify.verify) ViewColumn(io.prestosql.spi.connector.ConnectorViewDefinition.ViewColumn) Objects.requireNonNull(java.util.Objects.requireNonNull) GREATER_THAN(io.prestosql.spi.function.OperatorType.GREATER_THAN) QueryId(io.prestosql.spi.QueryId) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) ColumnMetadata(io.prestosql.spi.connector.ColumnMetadata) ConnectorTableHandle(io.prestosql.spi.connector.ConnectorTableHandle) TupleDomain(io.prestosql.spi.predicate.TupleDomain) ConnectorTableLayout(io.prestosql.spi.connector.ConnectorTableLayout) INVALID_VIEW(io.prestosql.spi.StandardErrorCode.INVALID_VIEW) Provider(com.google.inject.Provider) FeaturesConfig(io.prestosql.sql.analyzer.FeaturesConfig) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ConnectorInsertTableHandle(io.prestosql.spi.connector.ConnectorInsertTableHandle) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ImmutableSet(com.google.common.collect.ImmutableSet) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) GrantInfo(io.prestosql.spi.security.GrantInfo)

Example 18 with CatalogName

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

the class MetadataManager method executeDelete.

@Override
public OptionalLong executeDelete(Session session, TableHandle table) {
    CatalogName catalogName = table.getCatalogName();
    ConnectorMetadata metadata = getMetadataForWrite(session, catalogName);
    ConnectorSession connectorSession = session.toConnectorSession(catalogName);
    if (metadata.usesLegacyTableLayouts()) {
        checkArgument(table.getLayout().isPresent(), "table layout is missing");
        return metadata.metadataDelete(session.toConnectorSession(catalogName), table.getConnectorHandle(), table.getLayout().get());
    }
    checkArgument(!table.getLayout().isPresent(), "table layout should not be present");
    return metadata.executeDelete(connectorSession, table.getConnectorHandle());
}
Also used : CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorSession(io.prestosql.spi.connector.ConnectorSession) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Example 19 with CatalogName

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

the class MetadataManager method getTableMetadata.

@Override
public TableMetadata getTableMetadata(Session session, TableHandle tableHandle) {
    CatalogName catalogName = tableHandle.getCatalogName();
    ConnectorMetadata metadata = getMetadata(session, catalogName);
    ConnectorTableMetadata tableMetadata = metadata.getTableMetadata(session.toConnectorSession(catalogName), tableHandle.getConnectorHandle());
    if (tableMetadata.getColumns().isEmpty()) {
        throw new PrestoException(NOT_SUPPORTED, "Table has no columns: " + tableHandle);
    }
    return new TableMetadata(catalogName, tableMetadata);
}
Also used : ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata) CatalogName(io.prestosql.spi.connector.CatalogName) PrestoException(io.prestosql.spi.PrestoException) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata) ConnectorTableMetadata(io.prestosql.spi.connector.ConnectorTableMetadata)

Example 20 with CatalogName

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

the class MetadataManager method createRole.

// 
// Roles and Grants
// 
@Override
public void createRole(Session session, String role, Optional<PrestoPrincipal> grantor, String catalog) {
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalog);
    CatalogName catalogName = catalogMetadata.getCatalogName();
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    metadata.createRole(session.toConnectorSession(catalogName), role, grantor);
}
Also used : CatalogName(io.prestosql.spi.connector.CatalogName) ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Aggregations

CatalogName (io.prestosql.spi.connector.CatalogName)155 ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)82 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)32 TableHandle (io.prestosql.spi.metadata.TableHandle)30 PrestoException (io.prestosql.spi.PrestoException)22 ImmutableList (com.google.common.collect.ImmutableList)21 Optional (java.util.Optional)21 Session (io.prestosql.Session)20 QualifiedObjectName (io.prestosql.spi.connector.QualifiedObjectName)20 List (java.util.List)20 HashMap (java.util.HashMap)19 Map (java.util.Map)19 ConnectorDeleteAsInsertTableHandle (io.prestosql.spi.connector.ConnectorDeleteAsInsertTableHandle)18 ConnectorTableHandle (io.prestosql.spi.connector.ConnectorTableHandle)18 ConnectorInsertTableHandle (io.prestosql.spi.connector.ConnectorInsertTableHandle)17 ConnectorOutputTableHandle (io.prestosql.spi.connector.ConnectorOutputTableHandle)17 ConnectorUpdateTableHandle (io.prestosql.spi.connector.ConnectorUpdateTableHandle)17 ConnectorVacuumTableHandle (io.prestosql.spi.connector.ConnectorVacuumTableHandle)17 ConnectorTransactionHandle (io.prestosql.spi.connector.ConnectorTransactionHandle)16 Type (io.prestosql.spi.type.Type)16