Search in sources :

Example 11 with PartitioningHandle

use of com.facebook.presto.sql.planner.PartitioningHandle in project presto by prestodb.

the class MetadataManager method getPartitioningHandleForExchange.

@Override
public PartitioningHandle getPartitioningHandleForExchange(Session session, String catalogName, int partitionCount, List<Type> partitionTypes) {
    CatalogMetadata catalogMetadata = getOptionalCatalogMetadata(session, catalogName).orElseThrow(() -> new PrestoException(NOT_FOUND, format("Catalog '%s' does not exist", catalogName)));
    ConnectorId connectorId = catalogMetadata.getConnectorId();
    ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
    ConnectorPartitioningHandle connectorPartitioningHandle = metadata.getPartitioningHandleForExchange(session.toConnectorSession(connectorId), partitionCount, partitionTypes);
    ConnectorTransactionHandle transaction = catalogMetadata.getTransactionHandleFor(connectorId);
    return new PartitioningHandle(Optional.of(connectorId), Optional.of(transaction), connectorPartitioningHandle);
}
Also used : ConnectorPartitioningHandle(com.facebook.presto.spi.connector.ConnectorPartitioningHandle) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) PrestoException(com.facebook.presto.spi.PrestoException) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorPartitioningHandle(com.facebook.presto.spi.connector.ConnectorPartitioningHandle) PartitioningHandle(com.facebook.presto.sql.planner.PartitioningHandle) ConnectorId(com.facebook.presto.spi.ConnectorId)

Example 12 with PartitioningHandle

use of com.facebook.presto.sql.planner.PartitioningHandle in project presto by prestodb.

the class PrestoSparkRddFactory method createSparkRdd.

public <T extends PrestoSparkTaskOutput> JavaPairRDD<MutablePartitionId, T> createSparkRdd(JavaSparkContext sparkContext, Session session, PlanFragment fragment, Map<PlanFragmentId, JavaPairRDD<MutablePartitionId, PrestoSparkMutableRow>> rddInputs, Map<PlanFragmentId, Broadcast<?>> broadcastInputs, PrestoSparkTaskExecutorFactoryProvider executorFactoryProvider, CollectionAccumulator<SerializedTaskInfo> taskInfoCollector, CollectionAccumulator<PrestoSparkShuffleStats> shuffleStatsCollector, TableWriteInfo tableWriteInfo, Class<T> outputType) {
    checkArgument(!fragment.getStageExecutionDescriptor().isStageGroupedExecution(), "unexpected grouped execution fragment: %s", fragment.getId());
    PartitioningHandle partitioning = fragment.getPartitioning();
    if (partitioning.equals(SCALED_WRITER_DISTRIBUTION)) {
        throw new PrestoException(NOT_SUPPORTED, "Automatic writers scaling is not supported by Presto on Spark");
    }
    checkArgument(!partitioning.equals(COORDINATOR_DISTRIBUTION), "COORDINATOR_DISTRIBUTION fragment must be run on the driver");
    checkArgument(!partitioning.equals(FIXED_BROADCAST_DISTRIBUTION), "FIXED_BROADCAST_DISTRIBUTION can only be set as an output partitioning scheme, and not as a fragment distribution");
    checkArgument(!partitioning.equals(FIXED_PASSTHROUGH_DISTRIBUTION), "FIXED_PASSTHROUGH_DISTRIBUTION can only be set as local exchange partitioning");
    // TODO: ARBITRARY_DISTRIBUTION is something very weird.
    // TODO: It doesn't have partitioning function, and it is never set as a fragment partitioning.
    // TODO: We should consider removing ARBITRARY_DISTRIBUTION.
    checkArgument(!partitioning.equals(ARBITRARY_DISTRIBUTION), "ARBITRARY_DISTRIBUTION is not expected to be set as a fragment distribution");
    if (partitioning.equals(SINGLE_DISTRIBUTION) || partitioning.equals(FIXED_HASH_DISTRIBUTION) || partitioning.equals(FIXED_ARBITRARY_DISTRIBUTION) || partitioning.equals(SOURCE_DISTRIBUTION) || partitioning.getConnectorId().isPresent()) {
        for (RemoteSourceNode remoteSource : fragment.getRemoteSourceNodes()) {
            if (remoteSource.isEnsureSourceOrdering() || remoteSource.getOrderingScheme().isPresent()) {
                throw new PrestoException(NOT_SUPPORTED, format("Order sensitive exchange is not supported by Presto on Spark. fragmentId: %s, sourceFragmentIds: %s", fragment.getId(), remoteSource.getSourceFragmentIds()));
            }
        }
        return createRdd(sparkContext, session, fragment, executorFactoryProvider, taskInfoCollector, shuffleStatsCollector, tableWriteInfo, rddInputs, broadcastInputs, outputType);
    } else {
        throw new IllegalArgumentException(format("Unexpected fragment partitioning %s, fragmentId: %s", partitioning, fragment.getId()));
    }
}
Also used : RemoteSourceNode(com.facebook.presto.sql.planner.plan.RemoteSourceNode) PrestoException(com.facebook.presto.spi.PrestoException) PartitioningHandle(com.facebook.presto.sql.planner.PartitioningHandle)

Aggregations

PartitioningHandle (com.facebook.presto.sql.planner.PartitioningHandle)12 ImmutableList (com.google.common.collect.ImmutableList)6 ConnectorId (com.facebook.presto.spi.ConnectorId)5 RemoteSourceNode (com.facebook.presto.sql.planner.plan.RemoteSourceNode)5 ImmutableSet (com.google.common.collect.ImmutableSet)5 SplitSource (com.facebook.presto.split.SplitSource)4 PlanFragmentId (com.facebook.presto.sql.planner.plan.PlanFragmentId)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 Session (com.facebook.presto.Session)3 SqlStageExecution (com.facebook.presto.execution.SqlStageExecution)3 StageId (com.facebook.presto.execution.StageId)3 OutputBuffers (com.facebook.presto.execution.buffer.OutputBuffers)3 SplitSourceFactory (com.facebook.presto.sql.planner.SplitSourceFactory)3 List (java.util.List)3 SystemSessionProperties.getConcurrentLifespansPerNode (com.facebook.presto.SystemSessionProperties.getConcurrentLifespansPerNode)2 SystemSessionProperties.getMaxTasksPerStage (com.facebook.presto.SystemSessionProperties.getMaxTasksPerStage)2 SystemSessionProperties.getWriterMinSize (com.facebook.presto.SystemSessionProperties.getWriterMinSize)2 SystemSessionProperties.isOptimizedScaleWriterProducerBuffer (com.facebook.presto.SystemSessionProperties.isOptimizedScaleWriterProducerBuffer)2 ForQueryExecution (com.facebook.presto.execution.ForQueryExecution)2 NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)2