Search in sources :

Example 1 with ConnectorNodePartitioning

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

the class TpchMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    TpchTableHandle tableHandle = (TpchTableHandle) table;
    Optional<ConnectorNodePartitioning> nodePartition = Optional.empty();
    Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty();
    List<LocalProperty<ColumnHandle>> localProperties = ImmutableList.of();
    Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);
    if (tableHandle.getTableName().equals(TpchTable.ORDERS.getTableName())) {
        ColumnHandle orderKeyColumn = columns.get(OrderColumn.ORDER_KEY.getColumnName());
        nodePartition = Optional.of(new ConnectorNodePartitioning(new TpchPartitioningHandle(TpchTable.ORDERS.getTableName(), calculateTotalRows(OrderGenerator.SCALE_BASE, tableHandle.getScaleFactor())), ImmutableList.of(orderKeyColumn)));
        partitioningColumns = Optional.of(ImmutableSet.of(orderKeyColumn));
        localProperties = ImmutableList.of(new SortingProperty<>(orderKeyColumn, SortOrder.ASC_NULLS_FIRST));
    } else if (tableHandle.getTableName().equals(TpchTable.LINE_ITEM.getTableName())) {
        ColumnHandle orderKeyColumn = columns.get(OrderColumn.ORDER_KEY.getColumnName());
        nodePartition = Optional.of(new ConnectorNodePartitioning(new TpchPartitioningHandle(TpchTable.ORDERS.getTableName(), calculateTotalRows(OrderGenerator.SCALE_BASE, tableHandle.getScaleFactor())), ImmutableList.of(orderKeyColumn)));
        partitioningColumns = Optional.of(ImmutableSet.of(orderKeyColumn));
        localProperties = ImmutableList.of(new SortingProperty<>(orderKeyColumn, SortOrder.ASC_NULLS_FIRST), new SortingProperty<>(columns.get(LineItemColumn.LINE_NUMBER.getColumnName()), SortOrder.ASC_NULLS_FIRST));
    }
    ConnectorTableLayout layout = new ConnectorTableLayout(new TpchTableLayoutHandle(tableHandle), Optional.empty(), // TODO: return well-known properties (e.g., orderkey > 0, etc)
    TupleDomain.all(), nodePartition, partitioningColumns, Optional.empty(), localProperties);
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) SortingProperty(com.facebook.presto.spi.SortingProperty) ConnectorNodePartitioning(com.facebook.presto.spi.ConnectorNodePartitioning) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) LocalProperty(com.facebook.presto.spi.LocalProperty)

Aggregations

ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ConnectorNodePartitioning (com.facebook.presto.spi.ConnectorNodePartitioning)1 ConnectorTableLayout (com.facebook.presto.spi.ConnectorTableLayout)1 ConnectorTableLayoutResult (com.facebook.presto.spi.ConnectorTableLayoutResult)1 LocalProperty (com.facebook.presto.spi.LocalProperty)1 SortingProperty (com.facebook.presto.spi.SortingProperty)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Set (java.util.Set)1