Search in sources :

Example 11 with ConnectorMetadata

use of io.prestosql.spi.connector.ConnectorMetadata 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 12 with ConnectorMetadata

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

the class MetadataManager method resetInsertForRerun.

/**
 * Snapshot: Remove any previous changes from previous execution attempt, to prepare for query resume
 */
@Override
public void resetInsertForRerun(Session session, InsertTableHandle tableHandle, OptionalLong snapshotIndex) {
    ConnectorMetadata metadata = getMetadata(session, tableHandle.getCatalogName());
    metadata.resetInsertForRerun(session.toConnectorSession(tableHandle.getCatalogName()), tableHandle.getConnectorHandle(), snapshotIndex);
}
Also used : ConnectorMetadata(io.prestosql.spi.connector.ConnectorMetadata)

Example 13 with ConnectorMetadata

use of io.prestosql.spi.connector.ConnectorMetadata 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 14 with ConnectorMetadata

use of io.prestosql.spi.connector.ConnectorMetadata 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 15 with ConnectorMetadata

use of io.prestosql.spi.connector.ConnectorMetadata 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

ConnectorMetadata (io.prestosql.spi.connector.ConnectorMetadata)235 ConnectorSession (io.prestosql.spi.connector.ConnectorSession)126 Test (org.testng.annotations.Test)109 ConnectorTableHandle (io.prestosql.spi.connector.ConnectorTableHandle)103 TestingConnectorSession (io.prestosql.testing.TestingConnectorSession)96 CatalogName (io.prestosql.spi.connector.CatalogName)80 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)63 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)53 ConnectorTableMetadata (io.prestosql.spi.connector.ConnectorTableMetadata)52 HiveColumnHandle.bucketColumnHandle (io.prestosql.plugin.hive.HiveColumnHandle.bucketColumnHandle)44 ColumnMetadata (io.prestosql.spi.connector.ColumnMetadata)42 MaterializedResult (io.prestosql.testing.MaterializedResult)42 ConnectorInsertTableHandle (io.prestosql.spi.connector.ConnectorInsertTableHandle)41 ConnectorOutputTableHandle (io.prestosql.spi.connector.ConnectorOutputTableHandle)37 Constraint (io.prestosql.spi.connector.Constraint)35 Slice (io.airlift.slice.Slice)32 Path (org.apache.hadoop.fs.Path)32 PrestoException (io.prestosql.spi.PrestoException)31 HdfsContext (io.prestosql.plugin.hive.HdfsEnvironment.HdfsContext)30 ConnectorPageSink (io.prestosql.spi.connector.ConnectorPageSink)30