Search in sources :

Example 21 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class MetadataManager method getInfo.

@Override
public Optional<Object> getInfo(Session session, TableLayoutHandle handle) {
    ConnectorId connectorId = handle.getConnectorId();
    ConnectorMetadata metadata = getMetadata(session, connectorId);
    ConnectorTableLayout tableLayout = metadata.getTableLayout(session.toConnectorSession(connectorId), handle.getConnectorHandle());
    return metadata.getInfo(tableLayout.getHandle());
}
Also used : ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 22 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class ExampleMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    ExampleTableHandle tableHandle = (ExampleTableHandle) table;
    ConnectorTableLayout layout = new ConnectorTableLayout(new ExampleTableLayoutHandle(tableHandle));
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Example 23 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class KafkaMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    KafkaTableHandle handle = convertTableHandle(table);
    long startTimestamp = 0;
    long endTimestamp = 0;
    Optional<Map<ColumnHandle, Domain>> domains = constraint.getSummary().getDomains();
    if (domains.isPresent()) {
        Map<ColumnHandle, Domain> columnHandleDomainMap = domains.get();
        for (Map.Entry<ColumnHandle, Domain> entry : columnHandleDomainMap.entrySet()) {
            if (entry.getKey() instanceof KafkaColumnHandle && ((KafkaColumnHandle) entry.getKey()).getName().equals(KafkaInternalFieldDescription.OFFSET_TIMESTAMP_FIELD.getColumnName())) {
                Range span = entry.getValue().getValues().getRanges().getSpan();
                Marker low = span.getLow();
                Marker high = span.getHigh();
                if (!low.isLowerUnbounded()) {
                    startTimestamp = (long) low.getValue();
                }
                if (!high.isUpperUnbounded()) {
                    endTimestamp = (long) high.getValue();
                }
            }
        }
    }
    ConnectorTableLayout layout = new ConnectorTableLayout(new KafkaTableLayoutHandle(handle, startTimestamp, endTimestamp));
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : KafkaHandleResolver.convertColumnHandle(com.facebook.presto.kafka.KafkaHandleResolver.convertColumnHandle) ColumnHandle(com.facebook.presto.spi.ColumnHandle) Marker(com.facebook.presto.common.predicate.Marker) Range(com.facebook.presto.common.predicate.Range) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) Domain(com.facebook.presto.common.predicate.Domain) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 24 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class MongoMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    MongoTableHandle tableHandle = (MongoTableHandle) table;
    // TODO: sharding key
    Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty();
    ImmutableList.Builder<LocalProperty<ColumnHandle>> localProperties = ImmutableList.builder();
    MongoTable tableInfo = mongoSession.getTable(tableHandle.getSchemaTableName());
    Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);
    for (MongoIndex index : tableInfo.getIndexes()) {
        for (MongodbIndexKey key : index.getKeys()) {
            if (!key.getSortOrder().isPresent()) {
                continue;
            }
            if (columns.get(key.getName()) != null) {
                localProperties.add(new SortingProperty<>(columns.get(key.getName()), key.getSortOrder().get()));
            }
        }
    }
    ConnectorTableLayout layout = new ConnectorTableLayout(new MongoTableLayoutHandle(tableHandle, constraint.getSummary()), Optional.empty(), TupleDomain.all(), Optional.empty(), partitioningColumns, Optional.empty(), localProperties.build());
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) Set(java.util.Set) ImmutableList(com.google.common.collect.ImmutableList) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) MongodbIndexKey(com.facebook.presto.mongodb.MongoIndex.MongodbIndexKey) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) LocalProperty(com.facebook.presto.spi.LocalProperty)

Example 25 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class IcebergAbstractMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    IcebergTableHandle handle = (IcebergTableHandle) table;
    ConnectorTableLayout layout = new ConnectorTableLayout(new IcebergTableLayoutHandle(handle, constraint.getSummary()));
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Aggregations

ConnectorTableLayout (com.facebook.presto.spi.ConnectorTableLayout)39 ConnectorTableLayoutResult (com.facebook.presto.spi.ConnectorTableLayoutResult)27 ColumnHandle (com.facebook.presto.spi.ColumnHandle)11 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)11 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)10 ConnectorSession (com.facebook.presto.spi.ConnectorSession)8 Test (org.testng.annotations.Test)8 SchemaTableName (com.facebook.presto.spi.SchemaTableName)7 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)6 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)4 ConnectorSplitSource (com.facebook.presto.spi.ConnectorSplitSource)4 Set (java.util.Set)4 Domain (com.facebook.presto.common.predicate.Domain)3 HiveColumnHandle.bucketColumnHandle (com.facebook.presto.hive.HiveColumnHandle.bucketColumnHandle)3 Constraint (com.facebook.presto.spi.Constraint)3 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)2 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)2 ConnectorTableLayoutHandle (com.facebook.presto.spi.ConnectorTableLayoutHandle)2 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)2 ConnectorTablePartitioning (com.facebook.presto.spi.ConnectorTablePartitioning)2