Search in sources :

Example 1 with RowExpressionDeterminismEvaluator

use of com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator in project presto by prestodb.

the class TestRemoveUnsupportedDynamicFilters method setup.

@BeforeClass
public void setup() {
    metadata = getQueryRunner().getMetadata();
    logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(metadata.getFunctionAndTypeManager()), new FunctionResolution(metadata.getFunctionAndTypeManager()), metadata.getFunctionAndTypeManager());
    builder = new PlanBuilder(getQueryRunner().getDefaultSession(), new PlanNodeIdAllocator(), metadata);
    ConnectorId connectorId = getCurrentConnectorId();
    TableHandle lineitemTableHandle = new TableHandle(connectorId, new TpchTableHandle("lineitem", 1.0), TestingTransactionHandle.create(), Optional.empty());
    lineitemOrderKeyVariable = builder.variable("LINEITEM_OK", BIGINT);
    lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeyVariable), ImmutableMap.of(lineitemOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
    TableHandle ordersTableHandle = new TableHandle(connectorId, new TpchTableHandle("orders", 1.0), TestingTransactionHandle.create(), Optional.empty());
    ordersOrderKeyVariable = builder.variable("ORDERS_OK", BIGINT);
    ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeyVariable), ImmutableMap.of(ordersOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
}
Also used : RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) LogicalRowExpressions(com.facebook.presto.expressions.LogicalRowExpressions) TableHandle(com.facebook.presto.spi.TableHandle) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) FunctionResolution(com.facebook.presto.sql.relational.FunctionResolution) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) ConnectorId(com.facebook.presto.spi.ConnectorId) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with RowExpressionDeterminismEvaluator

use of com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator in project presto by prestodb.

the class TestDynamicFiltersChecker method setup.

@BeforeClass
public void setup() {
    metadata = getQueryRunner().getMetadata();
    logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(metadata.getFunctionAndTypeManager()), new FunctionResolution(metadata.getFunctionAndTypeManager()), metadata.getFunctionAndTypeManager());
    builder = new PlanBuilder(getQueryRunner().getDefaultSession(), new PlanNodeIdAllocator(), metadata);
    ConnectorId connectorId = getCurrentConnectorId();
    TableHandle lineitemTableHandle = new TableHandle(connectorId, new TpchTableHandle("lineitem", 1.0), TestingTransactionHandle.create(), Optional.empty());
    lineitemOrderKeyVariable = builder.variable("LINEITEM_OK", BIGINT);
    lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeyVariable), ImmutableMap.of(lineitemOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
    TableHandle ordersTableHandle = new TableHandle(connectorId, new TpchTableHandle("orders", 1.0), TestingTransactionHandle.create(), Optional.empty());
    ordersOrderKeyVariable = builder.variable("ORDERS_OK", BIGINT);
    ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeyVariable), ImmutableMap.of(ordersOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
}
Also used : RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) LogicalRowExpressions(com.facebook.presto.expressions.LogicalRowExpressions) TableHandle(com.facebook.presto.spi.TableHandle) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) FunctionResolution(com.facebook.presto.sql.relational.FunctionResolution) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) ConnectorId(com.facebook.presto.spi.ConnectorId) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with RowExpressionDeterminismEvaluator

use of com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator in project presto by prestodb.

the class LocalQueryRunner method createDrivers.

private List<Driver> createDrivers(Session session, Plan plan, OutputFactory outputFactory, TaskContext taskContext) {
    if (printPlan) {
        System.out.println(PlanPrinter.textLogicalPlan(plan.getRoot(), plan.getTypes(), metadata.getFunctionAndTypeManager(), plan.getStatsAndCosts(), session, 0, false));
    }
    SubPlan subplan = createSubPlans(session, plan, true);
    if (!subplan.getChildren().isEmpty()) {
        throw new AssertionError("Expected subplan to have no children");
    }
    LocalExecutionPlanner executionPlanner = new LocalExecutionPlanner(metadata, Optional.empty(), pageSourceManager, indexManager, partitioningProviderManager, nodePartitioningManager, pageSinkManager, distributedMetadataManager, expressionCompiler, pageFunctionCompiler, joinFilterFunctionCompiler, new IndexJoinLookupStats(), new TaskManagerConfig().setTaskConcurrency(4), new MemoryManagerConfig(), spillerFactory, singleStreamSpillerFactory, partitioningSpillerFactory, blockEncodingManager, new PagesIndex.TestingFactory(false), joinCompiler, new LookupJoinOperators(), new OrderingCompiler(), jsonCodec(TableCommitContext.class), new RowExpressionDeterminismEvaluator(metadata), new NoOpFragmentResultCacheManager(), new ObjectMapper(), standaloneSpillerFactory);
    // plan query
    StageExecutionDescriptor stageExecutionDescriptor = subplan.getFragment().getStageExecutionDescriptor();
    StreamingPlanSection streamingPlanSection = extractStreamingSections(subplan);
    checkState(streamingPlanSection.getChildren().isEmpty(), "expected no materialized exchanges");
    StreamingSubPlan streamingSubPlan = streamingPlanSection.getPlan();
    LocalExecutionPlan localExecutionPlan = executionPlanner.plan(taskContext, stageExecutionDescriptor, subplan.getFragment().getRoot(), subplan.getFragment().getPartitioningScheme(), subplan.getFragment().getTableScanSchedulingOrder(), outputFactory, Optional.empty(), new UnsupportedRemoteSourceFactory(), createTableWriteInfo(streamingSubPlan, metadata, session), false);
    // generate sources
    List<TaskSource> sources = new ArrayList<>();
    long sequenceId = 0;
    for (TableScanNode tableScan : findTableScanNodes(subplan.getFragment().getRoot())) {
        SplitSource splitSource = splitManager.getSplits(session, tableScan.getTable(), getSplitSchedulingStrategy(stageExecutionDescriptor, tableScan.getId()), WarningCollector.NOOP);
        ImmutableSet.Builder<ScheduledSplit> scheduledSplits = ImmutableSet.builder();
        while (!splitSource.isFinished()) {
            for (Split split : getNextBatch(splitSource)) {
                scheduledSplits.add(new ScheduledSplit(sequenceId++, tableScan.getId(), split));
            }
        }
        sources.add(new TaskSource(tableScan.getId(), scheduledSplits.build(), true));
    }
    // create drivers
    List<Driver> drivers = new ArrayList<>();
    Map<PlanNodeId, DriverFactory> driverFactoriesBySource = new HashMap<>();
    for (DriverFactory driverFactory : localExecutionPlan.getDriverFactories()) {
        for (int i = 0; i < driverFactory.getDriverInstances().orElse(1); i++) {
            if (driverFactory.getSourceId().isPresent()) {
                checkState(driverFactoriesBySource.put(driverFactory.getSourceId().get(), driverFactory) == null);
            } else {
                DriverContext driverContext = taskContext.addPipelineContext(driverFactory.getPipelineId(), driverFactory.isInputDriver(), driverFactory.isOutputDriver(), false).addDriverContext();
                Driver driver = driverFactory.createDriver(driverContext);
                drivers.add(driver);
            }
        }
    }
    // add sources to the drivers
    Set<PlanNodeId> tableScanPlanNodeIds = ImmutableSet.copyOf(subplan.getFragment().getTableScanSchedulingOrder());
    for (TaskSource source : sources) {
        DriverFactory driverFactory = driverFactoriesBySource.get(source.getPlanNodeId());
        checkState(driverFactory != null);
        boolean partitioned = tableScanPlanNodeIds.contains(driverFactory.getSourceId().get());
        for (ScheduledSplit split : source.getSplits()) {
            DriverContext driverContext = taskContext.addPipelineContext(driverFactory.getPipelineId(), driverFactory.isInputDriver(), driverFactory.isOutputDriver(), partitioned).addDriverContext();
            Driver driver = driverFactory.createDriver(driverContext);
            driver.updateSource(new TaskSource(split.getPlanNodeId(), ImmutableSet.of(split), true));
            drivers.add(driver);
        }
    }
    for (DriverFactory driverFactory : localExecutionPlan.getDriverFactories()) {
        driverFactory.noMoreDrivers();
    }
    return ImmutableList.copyOf(drivers);
}
Also used : DriverContext(com.facebook.presto.operator.DriverContext) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TableCommitContext(com.facebook.presto.operator.TableCommitContext) Driver(com.facebook.presto.operator.Driver) TaskManagerConfig(com.facebook.presto.execution.TaskManagerConfig) PagesIndex(com.facebook.presto.operator.PagesIndex) NoOpFragmentResultCacheManager(com.facebook.presto.operator.NoOpFragmentResultCacheManager) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) ImmutableSet(com.google.common.collect.ImmutableSet) OrderingCompiler(com.facebook.presto.sql.gen.OrderingCompiler) DriverFactory(com.facebook.presto.operator.DriverFactory) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LookupJoinOperators(com.facebook.presto.operator.LookupJoinOperators) RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) ScheduledSplit(com.facebook.presto.execution.ScheduledSplit) LocalExecutionPlanner(com.facebook.presto.sql.planner.LocalExecutionPlanner) IndexJoinLookupStats(com.facebook.presto.operator.index.IndexJoinLookupStats) StageExecutionDescriptor(com.facebook.presto.operator.StageExecutionDescriptor) MemoryManagerConfig(com.facebook.presto.memory.MemoryManagerConfig) LocalExecutionPlan(com.facebook.presto.sql.planner.LocalExecutionPlanner.LocalExecutionPlan) StreamingSubPlan(com.facebook.presto.execution.scheduler.StreamingSubPlan) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) StreamingPlanSection(com.facebook.presto.execution.scheduler.StreamingPlanSection) SplitSource(com.facebook.presto.split.SplitSource) Split(com.facebook.presto.metadata.Split) ScheduledSplit(com.facebook.presto.execution.ScheduledSplit) SubPlan(com.facebook.presto.sql.planner.SubPlan) StreamingSubPlan(com.facebook.presto.execution.scheduler.StreamingSubPlan) TaskSource(com.facebook.presto.execution.TaskSource)

Example 4 with RowExpressionDeterminismEvaluator

use of com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator in project presto by prestodb.

the class TestJoinNodeFlattener method setUp.

@BeforeClass
public void setUp() {
    queryRunner = new LocalQueryRunner(testSessionBuilder().build());
    determinismEvaluator = new RowExpressionDeterminismEvaluator(queryRunner.getMetadata());
    functionResolution = new FunctionResolution(queryRunner.getMetadata().getFunctionAndTypeManager());
}
Also used : RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) FunctionResolution(com.facebook.presto.sql.relational.FunctionResolution) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with RowExpressionDeterminismEvaluator

use of com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator in project presto by prestodb.

the class TestJoinEnumerator method setUp.

@BeforeClass
public void setUp() {
    queryRunner = new LocalQueryRunner(testSessionBuilder().build());
    metadata = queryRunner.getMetadata();
    determinismEvaluator = new RowExpressionDeterminismEvaluator(metadata);
    functionResolution = new FunctionResolution(metadata.getFunctionAndTypeManager());
}
Also used : RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) FunctionResolution(com.facebook.presto.sql.relational.FunctionResolution) LocalQueryRunner(com.facebook.presto.testing.LocalQueryRunner) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

RowExpressionDeterminismEvaluator (com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator)11 FunctionResolution (com.facebook.presto.sql.relational.FunctionResolution)6 LogicalRowExpressions (com.facebook.presto.expressions.LogicalRowExpressions)4 TableHandle (com.facebook.presto.spi.TableHandle)4 BeforeClass (org.testng.annotations.BeforeClass)4 Session (com.facebook.presto.Session)3 ConnectorId (com.facebook.presto.spi.ConnectorId)3 PlanNodeIdAllocator (com.facebook.presto.spi.plan.PlanNodeIdAllocator)3 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)3 RowExpression (com.facebook.presto.spi.relation.RowExpression)3 Optional (java.util.Optional)3 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)2 MemoryManagerConfig (com.facebook.presto.memory.MemoryManagerConfig)2 Metadata (com.facebook.presto.metadata.Metadata)2 Split (com.facebook.presto.metadata.Split)2 LookupJoinOperators (com.facebook.presto.operator.LookupJoinOperators)2 NoOpFragmentResultCacheManager (com.facebook.presto.operator.NoOpFragmentResultCacheManager)2 PagesIndex (com.facebook.presto.operator.PagesIndex)2 StageExecutionDescriptor (com.facebook.presto.operator.StageExecutionDescriptor)2 TableCommitContext (com.facebook.presto.operator.TableCommitContext)2