use of io.prestosql.spi.connector.ConnectorTablePartitioning in project hetu-core by openlookeng.
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));
}
return new ConnectorTableProperties(tableHandle.getConstraint(), tablePartitioning, partitioningColumns, Optional.empty(), localProperties);
}
use of io.prestosql.spi.connector.ConnectorTablePartitioning in project boostkit-bigdata by kunpengcompute.
the class HiveMetadata method getTableProperties.
@Override
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) {
HiveIdentity identity = new HiveIdentity(session);
HiveTableHandle hiveTable = (HiveTableHandle) table;
List<ColumnHandle> partitionColumns = ImmutableList.copyOf(hiveTable.getPartitionColumns());
List<HivePartition> partitions = partitionManager.getOrLoadPartitions(session, metastore, identity, hiveTable);
TupleDomain<ColumnHandle> predicate = createPredicate(partitionColumns, partitions);
if (hiveTable.isSuitableToPush()) {
Table hmsTable = metastore.getTable(identity, hiveTable.getSchemaName(), hiveTable.getTableName()).orElseThrow(() -> new TableNotFoundException(hiveTable.getSchemaTableName()));
ImmutableMap.Builder<ColumnHandle, Domain> pushedDown = ImmutableMap.builder();
pushedDown.putAll(hiveTable.getCompactEffectivePredicate().getDomains().get().entrySet().stream().collect(toMap(e -> (ColumnHandle) e.getKey(), e -> e.getValue())));
predicate = predicate.intersect(withColumnDomains(pushedDown.build()));
}
Optional<DiscretePredicates> discretePredicates = Optional.empty();
if (!partitionColumns.isEmpty()) {
// Do not create tuple domains for every partition at the same time!
// There can be a huge number of partitions so use an iterable so
// all domains do not need to be in memory at the same time.
Iterable<TupleDomain<ColumnHandle>> partitionDomains = Iterables.transform(partitions, (hivePartition) -> TupleDomain.fromFixedValues(hivePartition.getKeys()));
discretePredicates = Optional.of(new DiscretePredicates(partitionColumns, partitionDomains));
}
Optional<ConnectorTablePartitioning> tablePartitioning = Optional.empty();
if (HiveSessionProperties.isBucketExecutionEnabled(session) && hiveTable.getBucketHandle().isPresent()) {
tablePartitioning = hiveTable.getBucketHandle().map(bucketing -> new ConnectorTablePartitioning(new HivePartitioningHandle(bucketing.getBucketingVersion(), bucketing.getReadBucketCount(), bucketing.getColumns().stream().map(HiveColumnHandle::getHiveType).collect(toImmutableList()), OptionalInt.empty()), bucketing.getColumns().stream().map(ColumnHandle.class::cast).collect(toList())));
}
return new ConnectorTableProperties(predicate, tablePartitioning, Optional.empty(), discretePredicates, ImmutableList.of());
}
use of io.prestosql.spi.connector.ConnectorTablePartitioning in project hetu-core by openlookeng.
the class HiveMetadata method getTableProperties.
@Override
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) {
HiveIdentity identity = new HiveIdentity(session);
HiveTableHandle hiveTable = (HiveTableHandle) table;
List<ColumnHandle> partitionColumns = ImmutableList.copyOf(hiveTable.getPartitionColumns());
List<HivePartition> partitions = partitionManager.getOrLoadPartitions(session, metastore, identity, hiveTable);
TupleDomain<ColumnHandle> predicate = createPredicate(partitionColumns, partitions);
if (hiveTable.isSuitableToPush()) {
Table hmsTable = metastore.getTable(identity, hiveTable.getSchemaName(), hiveTable.getTableName()).orElseThrow(() -> new TableNotFoundException(hiveTable.getSchemaTableName()));
ImmutableMap.Builder<ColumnHandle, Domain> pushedDown = ImmutableMap.builder();
pushedDown.putAll(hiveTable.getCompactEffectivePredicate().getDomains().get().entrySet().stream().collect(toMap(e -> (ColumnHandle) e.getKey(), e -> e.getValue())));
predicate = predicate.intersect(withColumnDomains(pushedDown.build()));
}
Optional<DiscretePredicates> discretePredicates = Optional.empty();
if (!partitionColumns.isEmpty()) {
// Do not create tuple domains for every partition at the same time!
// There can be a huge number of partitions so use an iterable so
// all domains do not need to be in memory at the same time.
Iterable<TupleDomain<ColumnHandle>> partitionDomains = Iterables.transform(partitions, (hivePartition) -> TupleDomain.fromFixedValues(hivePartition.getKeys()));
discretePredicates = Optional.of(new DiscretePredicates(partitionColumns, partitionDomains));
}
Optional<ConnectorTablePartitioning> tablePartitioning = Optional.empty();
if (HiveSessionProperties.isBucketExecutionEnabled(session) && hiveTable.getBucketHandle().isPresent()) {
tablePartitioning = hiveTable.getBucketHandle().map(bucketing -> new ConnectorTablePartitioning(new HivePartitioningHandle(bucketing.getBucketingVersion(), bucketing.getReadBucketCount(), bucketing.getColumns().stream().map(HiveColumnHandle::getHiveType).collect(toImmutableList()), OptionalInt.empty()), bucketing.getColumns().stream().map(ColumnHandle.class::cast).collect(toList())));
}
return new ConnectorTableProperties(predicate, tablePartitioning, Optional.empty(), discretePredicates, ImmutableList.of());
}
Aggregations