Search in sources :

Example 16 with ConnectorTableProperties

use of io.trino.spi.connector.ConnectorTableProperties in project trino by trinodb.

the class TpchMetadata method getTableProperties.

@Override
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) {
    TpchTableHandle tableHandle = (TpchTableHandle) table;
    Optional<ConnectorTablePartitioning> tablePartitioning = Optional.empty();
    Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty();
    List<LocalProperty<ColumnHandle>> localProperties = ImmutableList.of();
    Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);
    if (partitioningEnabled && tableHandle.getTableName().equals(TpchTable.ORDERS.getTableName())) {
        ColumnHandle orderKeyColumn = columns.get(columnNaming.getName(OrderColumn.ORDER_KEY));
        tablePartitioning = Optional.of(new ConnectorTablePartitioning(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 (partitioningEnabled && tableHandle.getTableName().equals(TpchTable.LINE_ITEM.getTableName())) {
        ColumnHandle orderKeyColumn = columns.get(columnNaming.getName(LineItemColumn.ORDER_KEY));
        tablePartitioning = Optional.of(new ConnectorTablePartitioning(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(columnNaming.getName(LineItemColumn.LINE_NUMBER)), SortOrder.ASC_NULLS_FIRST));
    }
    TupleDomain<ColumnHandle> constraint = tableHandle.getConstraint();
    if (predicatePushdownEnabled && constraint.isAll()) {
        if (tableHandle.getTableName().equals(TpchTable.ORDERS.getTableName())) {
            constraint = toTupleDomain(ImmutableMap.of(toColumnHandle(OrderColumn.ORDER_STATUS), orderStatusNullableValues));
        } else if (tableHandle.getTableName().equals(TpchTable.PART.getTableName())) {
            constraint = toTupleDomain(ImmutableMap.of(toColumnHandle(PartColumn.CONTAINER), partContainerNullableValues, toColumnHandle(PartColumn.TYPE), partTypeNullableValues));
        }
    }
    return new ConnectorTableProperties(constraint, tablePartitioning, partitioningColumns, Optional.empty(), localProperties);
}
Also used : ColumnHandle(io.trino.spi.connector.ColumnHandle) Collectors.toSet(java.util.stream.Collectors.toSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) ConnectorTablePartitioning(io.trino.spi.connector.ConnectorTablePartitioning) SortingProperty(io.trino.spi.connector.SortingProperty) LocalProperty(io.trino.spi.connector.LocalProperty) ConnectorTableProperties(io.trino.spi.connector.ConnectorTableProperties)

Aggregations

ConnectorTableProperties (io.trino.spi.connector.ConnectorTableProperties)16 ColumnHandle (io.trino.spi.connector.ColumnHandle)13 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)10 ImmutableList (com.google.common.collect.ImmutableList)8 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)7 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)7 ConnectorMetadata (io.trino.spi.connector.ConnectorMetadata)7 ConnectorSession (io.trino.spi.connector.ConnectorSession)7 SortingProperty (io.trino.spi.connector.SortingProperty)7 SchemaTableName (io.trino.spi.connector.SchemaTableName)6 Test (org.testng.annotations.Test)6 ImmutableMap (com.google.common.collect.ImmutableMap)5 Constraint (io.trino.spi.connector.Constraint)5 TupleDomain (io.trino.spi.predicate.TupleDomain)5 List (java.util.List)5 Optional (java.util.Optional)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 Slice (io.airlift.slice.Slice)4 HiveColumnHandle.bucketColumnHandle (io.trino.plugin.hive.HiveColumnHandle.bucketColumnHandle)4 ConnectorOutputTableHandle (io.trino.spi.connector.ConnectorOutputTableHandle)4