Search in sources :

Example 16 with PlanNodeId

use of io.prestosql.spi.plan.PlanNodeId in project hetu-core by openlookeng.

the class PlanPrinter method textDistributedPlan.

public static String textDistributedPlan(StageInfo outputStageInfo, ValuePrinter valuePrinter, boolean verbose, Metadata metadata) {
    Map<PlanNodeId, TableInfo> tableInfos = getAllStages(Optional.of(outputStageInfo)).stream().map(StageInfo::getTables).map(Map::entrySet).flatMap(Collection::stream).collect(toImmutableMap(Entry::getKey, Entry::getValue));
    StringBuilder builder = new StringBuilder();
    List<StageInfo> allStages = getAllStages(Optional.of(outputStageInfo));
    List<PlanFragment> allFragments = allStages.stream().map(StageInfo::getPlan).collect(toImmutableList());
    Map<PlanNodeId, PlanNodeStats> aggregatedStats = aggregateStageStats(allStages);
    for (StageInfo stageInfo : allStages) {
        builder.append(formatFragment(tableScanNode -> tableInfos.get(tableScanNode.getId()), valuePrinter, stageInfo.getPlan(), Optional.of(stageInfo), Optional.of(aggregatedStats), verbose, allFragments, metadata));
    }
    return builder.toString();
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TableDeleteNode(io.prestosql.sql.planner.plan.TableDeleteNode) SortNode(io.prestosql.sql.planner.plan.SortNode) SubPlan(io.prestosql.sql.planner.SubPlan) LogicalRowExpressions(io.prestosql.expressions.LogicalRowExpressions) REUSE_STRATEGY_PRODUCER(io.prestosql.spi.operator.ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_PRODUCER) TypeProvider(io.prestosql.sql.planner.TypeProvider) NullableValue(io.prestosql.spi.predicate.NullableValue) PlanFragmentId(io.prestosql.sql.planner.plan.PlanFragmentId) CTEScanNode(io.prestosql.spi.plan.CTEScanNode) AggregationNode(io.prestosql.spi.plan.AggregationNode) TableUpdateNode(io.prestosql.sql.planner.plan.TableUpdateNode) Map(java.util.Map) OutputNode(io.prestosql.sql.planner.plan.OutputNode) Partitioning(io.prestosql.sql.planner.Partitioning) TopNRankingNumberNode(io.prestosql.sql.planner.plan.TopNRankingNumberNode) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TypedSymbol(io.prestosql.sql.planner.planprinter.NodeRepresentation.TypedSymbol) RowExpressionDeterminismEvaluator(io.prestosql.sql.relational.RowExpressionDeterminismEvaluator) CreateIndexNode(io.prestosql.sql.planner.plan.CreateIndexNode) SortExpressionContext(io.prestosql.sql.planner.SortExpressionContext) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) TableScanNode(io.prestosql.spi.plan.TableScanNode) Set(java.util.Set) DynamicFilters(io.prestosql.sql.DynamicFilters) IndexSourceNode(io.prestosql.sql.planner.plan.IndexSourceNode) PlanNode(io.prestosql.spi.plan.PlanNode) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) ProjectNode(io.prestosql.spi.plan.ProjectNode) Metadata(io.prestosql.metadata.Metadata) Collectors.joining(java.util.stream.Collectors.joining) SymbolUtils.toSymbolReference(io.prestosql.sql.planner.SymbolUtils.toSymbolReference) SpatialJoinNode(io.prestosql.sql.planner.plan.SpatialJoinNode) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) Stream(java.util.stream.Stream) Domain(io.prestosql.spi.predicate.Domain) StatisticAggregations(io.prestosql.sql.planner.plan.StatisticAggregations) ColumnStatisticMetadata(io.prestosql.spi.statistics.ColumnStatisticMetadata) StatisticsWriterNode(io.prestosql.sql.planner.plan.StatisticsWriterNode) VacuumTableNode(io.prestosql.sql.planner.plan.VacuumTableNode) DistinctLimitNode(io.prestosql.sql.planner.plan.DistinctLimitNode) Joiner(com.google.common.base.Joiner) GroupIdNode(io.prestosql.spi.plan.GroupIdNode) Iterables(com.google.common.collect.Iterables) IntersectNode(io.prestosql.spi.plan.IntersectNode) Marker(io.prestosql.spi.predicate.Marker) DynamicFilters.extractDynamicFilters(io.prestosql.sql.DynamicFilters.extractDynamicFilters) StageExecutionDescriptor(io.prestosql.operator.StageExecutionDescriptor) AssignUniqueId(io.prestosql.sql.planner.plan.AssignUniqueId) UnnestNode(io.prestosql.sql.planner.plan.UnnestNode) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) Session(io.prestosql.Session) DeleteNode(io.prestosql.sql.planner.plan.DeleteNode) Functions(com.google.common.base.Functions) PlanNodeStatsEstimate(io.prestosql.cost.PlanNodeStatsEstimate) Assignments(io.prestosql.spi.plan.Assignments) ComparisonExpression(io.prestosql.sql.tree.ComparisonExpression) VariableReferenceExpression(io.prestosql.spi.relation.VariableReferenceExpression) TextRenderer.formatPositions(io.prestosql.sql.planner.planprinter.TextRenderer.formatPositions) ValuesNode(io.prestosql.spi.plan.ValuesNode) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) SampleNode(io.prestosql.sql.planner.plan.SampleNode) WindowNode(io.prestosql.spi.plan.WindowNode) LimitNode(io.prestosql.spi.plan.LimitNode) Expression(io.prestosql.sql.tree.Expression) OffsetNode(io.prestosql.sql.planner.plan.OffsetNode) StatisticAggregationsDescriptor(io.prestosql.sql.planner.plan.StatisticAggregationsDescriptor) Scope(io.prestosql.sql.planner.plan.ExchangeNode.Scope) UpdateIndexNode(io.prestosql.sql.planner.plan.UpdateIndexNode) Duration(io.airlift.units.Duration) PlanNodeStatsSummarizer.aggregateStageStats(io.prestosql.sql.planner.planprinter.PlanNodeStatsSummarizer.aggregateStageStats) TableStatisticType(io.prestosql.spi.statistics.TableStatisticType) PartitioningScheme(io.prestosql.sql.planner.PartitioningScheme) TableFinishNode(io.prestosql.sql.planner.plan.TableFinishNode) PlanCostEstimate(io.prestosql.cost.PlanCostEstimate) ExchangeNode(io.prestosql.sql.planner.plan.ExchangeNode) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) FilterNode(io.prestosql.spi.plan.FilterNode) TextRenderer.indentString(io.prestosql.sql.planner.planprinter.TextRenderer.indentString) TextRenderer.formatDouble(io.prestosql.sql.planner.planprinter.TextRenderer.formatDouble) Type(io.prestosql.spi.type.Type) ApplyNode(io.prestosql.sql.planner.plan.ApplyNode) ImmutableSet(com.google.common.collect.ImmutableSet) JoinNodeUtils(io.prestosql.sql.planner.optimizations.JoinNodeUtils) Collection(java.util.Collection) Streams(com.google.common.collect.Streams) IndexJoinNode(io.prestosql.sql.planner.plan.IndexJoinNode) CubeFinishNode(io.prestosql.sql.planner.plan.CubeFinishNode) Collectors(java.util.stream.Collectors) RowNumberNode(io.prestosql.sql.planner.plan.RowNumberNode) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) List(java.util.List) FunctionResolution(io.prestosql.sql.relational.FunctionResolution) EnforceSingleRowNode(io.prestosql.sql.planner.plan.EnforceSingleRowNode) TopNNode(io.prestosql.spi.plan.TopNNode) StageInfo.getAllStages(io.prestosql.execution.StageInfo.getAllStages) StageInfo(io.prestosql.execution.StageInfo) Entry(java.util.Map.Entry) UnionNode(io.prestosql.spi.plan.UnionNode) Optional(java.util.Optional) ExceptNode(io.prestosql.spi.plan.ExceptNode) Arrays.stream(java.util.Arrays.stream) StageStats(io.prestosql.execution.StageStats) InternalPlanVisitor(io.prestosql.sql.planner.plan.InternalPlanVisitor) SINGLE_DISTRIBUTION(io.prestosql.sql.planner.SystemPartitioningHandle.SINGLE_DISTRIBUTION) LateralJoinNode(io.prestosql.sql.planner.plan.LateralJoinNode) StatsAndCosts(io.prestosql.cost.StatsAndCosts) RemoteSourceNode(io.prestosql.sql.planner.plan.RemoteSourceNode) TableHandle(io.prestosql.spi.metadata.TableHandle) Function(java.util.function.Function) TRUE_LITERAL(io.prestosql.sql.tree.BooleanLiteral.TRUE_LITERAL) SemiJoinNode(io.prestosql.sql.planner.plan.SemiJoinNode) ImmutableList(com.google.common.collect.ImmutableList) OrderingScheme(io.prestosql.spi.plan.OrderingScheme) GraphvizPrinter(io.prestosql.util.GraphvizPrinter) Verify.verify(com.google.common.base.Verify.verify) Range(io.prestosql.spi.predicate.Range) Objects.requireNonNull(java.util.Objects.requireNonNull) LinkedList(java.util.LinkedList) MarkDistinctNode(io.prestosql.spi.plan.MarkDistinctNode) JoinNode(io.prestosql.spi.plan.JoinNode) Symbol(io.prestosql.spi.plan.Symbol) PlanFragment(io.prestosql.sql.planner.PlanFragment) TableWriterNode(io.prestosql.sql.planner.plan.TableWriterNode) StageExecutionDescriptor.ungroupedExecution(io.prestosql.operator.StageExecutionDescriptor.ungroupedExecution) REUSE_STRATEGY_CONSUMER(io.prestosql.spi.operator.ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_CONSUMER) TableInfo(io.prestosql.execution.TableInfo) CaseFormat(com.google.common.base.CaseFormat) GroupReference(io.prestosql.spi.plan.GroupReference) TupleDomain(io.prestosql.spi.predicate.TupleDomain) UpdateNode(io.prestosql.sql.planner.plan.UpdateNode) UPPER_UNDERSCORE(com.google.common.base.CaseFormat.UPPER_UNDERSCORE) Collectors.toList(java.util.stream.Collectors.toList) Aggregation(io.prestosql.spi.plan.AggregationNode.Aggregation) RowExpression(io.prestosql.spi.relation.RowExpression) SortExpressionExtractor(io.prestosql.sql.planner.SortExpressionExtractor) ExplainAnalyzeNode(io.prestosql.sql.planner.plan.ExplainAnalyzeNode) StageInfo(io.prestosql.execution.StageInfo) TableInfo(io.prestosql.execution.TableInfo) Map(java.util.Map) ImmutableMap.toImmutableMap(com.google.common.collect.ImmutableMap.toImmutableMap) PlanFragment(io.prestosql.sql.planner.PlanFragment)

Example 17 with PlanNodeId

use of io.prestosql.spi.plan.PlanNodeId in project hetu-core by openlookeng.

the class TestHashJoinOperator method testYield.

@Test
public void testYield() {
    // create a filter function that yields for every probe match
    // verify we will yield #match times totally
    TaskContext taskContext = createTaskContext();
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // force a yield for every match
    AtomicInteger filterFunctionCalls = new AtomicInteger();
    InternalJoinFilterFunction filterFunction = new TestInternalJoinFilterFunction(((leftPosition, leftPage, rightPosition, rightPage) -> {
        filterFunctionCalls.incrementAndGet();
        driverContext.getYieldSignal().forceYieldForTesting();
        return true;
    }));
    // build with 40 entries
    int entries = 40;
    RowPagesBuilder buildPages = rowPagesBuilder(true, Ints.asList(0), ImmutableList.of(BIGINT)).addSequencePage(entries, 42);
    BuildSideSetup buildSideSetup = setupBuildSide(true, taskContext, Ints.asList(0), buildPages, Optional.of(filterFunction), false, SINGLE_STREAM_SPILLER_FACTORY);
    JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactory = buildSideSetup.getLookupSourceFactoryManager();
    // probe matching the above 40 entries
    RowPagesBuilder probePages = rowPagesBuilder(false, Ints.asList(0), ImmutableList.of(BIGINT));
    List<Page> probeInput = probePages.addSequencePage(100, 0).build();
    OperatorFactory joinOperatorFactory = LOOKUP_JOIN_OPERATORS.innerJoin(0, new PlanNodeId("test"), lookupSourceFactory, probePages.getTypes(), Ints.asList(0), getHashChannelAsInt(probePages), Optional.empty(), OptionalInt.of(1), PARTITIONING_SPILLER_FACTORY);
    instantiateBuildDrivers(buildSideSetup, taskContext);
    buildLookupSource(buildSideSetup);
    Operator operator = joinOperatorFactory.createOperator(driverContext);
    assertTrue(operator.needsInput());
    operator.addInput(probeInput.get(0));
    operator.finish();
    // we will yield 40 times due to filterFunction
    for (int i = 0; i < entries; i++) {
        driverContext.getYieldSignal().setWithDelay(5 * SECONDS.toNanos(1), driverContext.getYieldExecutor());
        filterFunctionCalls.set(0);
        assertNull(operator.getOutput());
        assertEquals(filterFunctionCalls.get(), 1, "Expected join to stop processing (yield) after calling filter function once");
        driverContext.getYieldSignal().reset();
    }
    // delayed yield is not going to prevent operator from producing a page now (yield won't be forced because filter function won't be called anymore)
    driverContext.getYieldSignal().setWithDelay(5 * SECONDS.toNanos(1), driverContext.getYieldExecutor());
    // expect output page to be produced within few calls to getOutput(), e.g. to facilitate spill
    Page output = null;
    for (int i = 0; output == null && i < 5; i++) {
        output = operator.getOutput();
    }
    assertNotNull(output);
    driverContext.getYieldSignal().reset();
    // make sure we have all 4 entries
    assertEquals(output.getPositionCount(), entries);
}
Also used : Arrays(java.util.Arrays) TaskStateMachine(io.prestosql.execution.TaskStateMachine) OperatorAssertion.without(io.prestosql.operator.OperatorAssertion.without) Test(org.testng.annotations.Test) AfterMethod(org.testng.annotations.AfterMethod) ImmutableRoaringBitmap(org.roaringbitmap.buffer.ImmutableRoaringBitmap) Collections.singletonList(java.util.Collections.singletonList) Assert.assertEquals(io.prestosql.testing.assertions.Assert.assertEquals) Future(java.util.concurrent.Future) Executors.newScheduledThreadPool(java.util.concurrent.Executors.newScheduledThreadPool) Arrays.asList(java.util.Arrays.asList) SingleStreamSpillerFactory(io.prestosql.spiller.SingleStreamSpillerFactory) Map(java.util.Map) Path(java.nio.file.Path) Assert.assertFalse(org.testng.Assert.assertFalse) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) JoinFilterFunctionFactory(io.prestosql.sql.gen.JoinFilterFunctionCompiler.JoinFilterFunctionFactory) Iterators.unmodifiableIterator(com.google.common.collect.Iterators.unmodifiableIterator) OperatorAssertion.assertOperatorEqualsWithSimpleStateComparison(io.prestosql.operator.OperatorAssertion.assertOperatorEqualsWithSimpleStateComparison) ExceededMemoryLimitException(io.prestosql.ExceededMemoryLimitException) GENERIC_INTERNAL_ERROR(io.prestosql.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR) TEST_SESSION(io.prestosql.SessionTestUtils.TEST_SESSION) Iterables(com.google.common.collect.Iterables) FIXED_HASH_DISTRIBUTION(io.prestosql.sql.planner.SystemPartitioningHandle.FIXED_HASH_DISTRIBUTION) OperatorAssertion.dropChannel(io.prestosql.operator.OperatorAssertion.dropChannel) ArrayList(java.util.ArrayList) VARCHAR(io.prestosql.spi.type.VarcharType.VARCHAR) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Lifespan(io.prestosql.execution.Lifespan) Futures.immediateFuture(com.google.common.util.concurrent.Futures.immediateFuture) ValuesOperatorFactory(io.prestosql.operator.ValuesOperator.ValuesOperatorFactory) LocalExchangeSinkOperatorFactory(io.prestosql.operator.exchange.LocalExchangeSinkOperator.LocalExchangeSinkOperatorFactory) MoreFutures.getFutureValue(io.airlift.concurrent.MoreFutures.getFutureValue) MaterializedRow(io.prestosql.testing.MaterializedRow) ExecutionException(java.util.concurrent.ExecutionException) RowPagesBuilder(io.prestosql.RowPagesBuilder) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) PageBuffer(io.prestosql.operator.index.PageBuffer) SingleStreamSpiller(io.prestosql.spiller.SingleStreamSpiller) RoaringBitmap(org.roaringbitmap.RoaringBitmap) MaterializedResult(io.prestosql.testing.MaterializedResult) ByteBuffer(java.nio.ByteBuffer) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) OperatorAssertion.assertOperatorEquals(io.prestosql.operator.OperatorAssertion.assertOperatorEquals) Type(io.prestosql.spi.type.Type) BIGINT(io.prestosql.spi.type.BigintType.BIGINT) LocalExchangeSinkFactoryId(io.prestosql.operator.exchange.LocalExchange.LocalExchangeSinkFactoryId) PartitioningSpillerFactory(io.prestosql.spiller.PartitioningSpillerFactory) PrestoException(io.prestosql.spi.PrestoException) ImmutableSet(com.google.common.collect.ImmutableSet) MarkerPage(io.prestosql.spi.snapshot.MarkerPage) ImmutableMap(com.google.common.collect.ImmutableMap) SynchronousQueue(java.util.concurrent.SynchronousQueue) Collections.nCopies(java.util.Collections.nCopies) RowPagesBuilder.rowPagesBuilder(io.prestosql.RowPagesBuilder.rowPagesBuilder) BeforeMethod(org.testng.annotations.BeforeMethod) GenericPartitioningSpillerFactory(io.prestosql.spiller.GenericPartitioningSpillerFactory) Assert.assertNotNull(org.testng.Assert.assertNotNull) String.format(java.lang.String.format) Preconditions.checkState(com.google.common.base.Preconditions.checkState) TEST_SNAPSHOT_SESSION(io.prestosql.SessionTestUtils.TEST_SNAPSHOT_SESSION) DataSize(io.airlift.units.DataSize) List(java.util.List) Optional(java.util.Optional) Booleans(com.google.common.primitives.Booleans) LocalExchangeSourceOperator(io.prestosql.operator.exchange.LocalExchangeSourceOperator) IntStream(java.util.stream.IntStream) TaskId(io.prestosql.execution.TaskId) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) LocalExchangeFactory(io.prestosql.operator.exchange.LocalExchange.LocalExchangeFactory) DataProvider(org.testng.annotations.DataProvider) Assert.assertNull(org.testng.Assert.assertNull) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) RestorableConfig(io.prestosql.spi.snapshot.RestorableConfig) OptionalInt(java.util.OptionalInt) Function(java.util.function.Function) Iterators(com.google.common.collect.Iterators) ImmutableList(com.google.common.collect.ImmutableList) Threads.daemonThreadsNamed(io.airlift.concurrent.Threads.daemonThreadsNamed) Objects.requireNonNull(java.util.Objects.requireNonNull) ExecutorService(java.util.concurrent.ExecutorService) LocalMemoryContext(io.prestosql.memory.context.LocalMemoryContext) Iterator(java.util.Iterator) LocalExchangeSourceOperatorFactory(io.prestosql.operator.exchange.LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory) Assert.fail(org.testng.Assert.fail) Page(io.prestosql.spi.Page) TestingTaskContext(io.prestosql.testing.TestingTaskContext) Ints(com.google.common.primitives.Ints) TimeUnit(java.util.concurrent.TimeUnit) PageBufferOperatorFactory(io.prestosql.operator.index.PageBufferOperator.PageBufferOperatorFactory) Assertions.assertEqualsIgnoreOrder(io.airlift.testing.Assertions.assertEqualsIgnoreOrder) Collectors.toList(java.util.stream.Collectors.toList) Futures.immediateFailedFuture(com.google.common.util.concurrent.Futures.immediateFailedFuture) UNGROUPED_EXECUTION(io.prestosql.operator.PipelineExecutionStrategy.UNGROUPED_EXECUTION) Assert.assertTrue(org.testng.Assert.assertTrue) Comparator(java.util.Comparator) BYTE(io.airlift.units.DataSize.Unit.BYTE) SECONDS(java.util.concurrent.TimeUnit.SECONDS) LocalExchangeSourceOperator(io.prestosql.operator.exchange.LocalExchangeSourceOperator) TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) MarkerPage(io.prestosql.spi.snapshot.MarkerPage) Page(io.prestosql.spi.Page) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ValuesOperatorFactory(io.prestosql.operator.ValuesOperator.ValuesOperatorFactory) LocalExchangeSinkOperatorFactory(io.prestosql.operator.exchange.LocalExchangeSinkOperator.LocalExchangeSinkOperatorFactory) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) LocalExchangeSourceOperatorFactory(io.prestosql.operator.exchange.LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory) PageBufferOperatorFactory(io.prestosql.operator.index.PageBufferOperator.PageBufferOperatorFactory) Test(org.testng.annotations.Test)

Example 18 with PlanNodeId

use of io.prestosql.spi.plan.PlanNodeId in project hetu-core by openlookeng.

the class TestHashJoinOperator method testInnerJoinWithNonEmptyLookupSourceAndEmptyProbe.

@Test(dataProvider = "hashJoinTestValues")
public void testInnerJoinWithNonEmptyLookupSourceAndEmptyProbe(boolean parallelBuild, boolean probeHashEnabled, boolean buildHashEnabled) {
    TaskContext taskContext = createTaskContext();
    // build factory
    List<Type> buildTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder buildPages = rowPagesBuilder(buildHashEnabled, Ints.asList(0), buildTypes).row("a").row("b").row((String) null).row("c");
    BuildSideSetup buildSideSetup = setupBuildSide(parallelBuild, taskContext, Ints.asList(0), buildPages, Optional.empty(), false, SINGLE_STREAM_SPILLER_FACTORY);
    JoinBridgeManager<PartitionedLookupSourceFactory> lookupSourceFactoryManager = buildSideSetup.getLookupSourceFactoryManager();
    // probe factory
    List<Type> probeTypes = ImmutableList.of(VARCHAR);
    RowPagesBuilder probePages = rowPagesBuilder(probeHashEnabled, Ints.asList(0), probeTypes);
    List<Page> probeInput = probePages.build();
    OperatorFactory joinOperatorFactory = new LookupJoinOperators().innerJoin(0, new PlanNodeId("test"), lookupSourceFactoryManager, probePages.getTypes(), Ints.asList(0), getHashChannelAsInt(probePages), Optional.empty(), OptionalInt.of(1), PARTITIONING_SPILLER_FACTORY);
    // build drivers and operators
    instantiateBuildDrivers(buildSideSetup, taskContext);
    buildLookupSource(buildSideSetup);
    // expected
    MaterializedResult expected = MaterializedResult.resultBuilder(taskContext.getSession(), concat(probeTypes, buildTypes)).build();
    assertOperatorEquals(joinOperatorFactory, taskContext.addPipelineContext(0, true, true, false).addDriverContext(), probeInput, expected, true, getHashChannels(probePages, buildPages));
}
Also used : TestingTaskContext(io.prestosql.testing.TestingTaskContext) RowPagesBuilder(io.prestosql.RowPagesBuilder) MarkerPage(io.prestosql.spi.snapshot.MarkerPage) Page(io.prestosql.spi.Page) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) ValuesOperatorFactory(io.prestosql.operator.ValuesOperator.ValuesOperatorFactory) LocalExchangeSinkOperatorFactory(io.prestosql.operator.exchange.LocalExchangeSinkOperator.LocalExchangeSinkOperatorFactory) HashBuilderOperatorFactory(io.prestosql.operator.HashBuilderOperator.HashBuilderOperatorFactory) LocalExchangeSourceOperatorFactory(io.prestosql.operator.exchange.LocalExchangeSourceOperator.LocalExchangeSourceOperatorFactory) PageBufferOperatorFactory(io.prestosql.operator.index.PageBufferOperator.PageBufferOperatorFactory) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 19 with PlanNodeId

use of io.prestosql.spi.plan.PlanNodeId in project hetu-core by openlookeng.

the class TestHashSemiJoinOperator method testBuildSideNulls.

@Test(dataProvider = "hashEnabledValues")
public void testBuildSideNulls(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    List<Type> buildTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), buildTypes);
    Operator buildOperator = createValuesOperator(operatorContext, rowPagesBuilder.row(0L).row(1L).row(2L).row(2L).row(3L).row((Object) null).build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), buildTypes.get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(createTestMetadataManager()));
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), probeTypes);
    List<Page> probeInput = rowPagesBuilderProbe.addSequencePage(4, 1).build();
    Optional<Integer> probeHashChannel = hashEnabled ? Optional.of(probeTypes.size()) : Optional.empty();
    HashSemiJoinOperatorFactory joinOperatorFactory = new HashSemiJoinOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0, probeHashChannel);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row(1L, true).row(2L, true).row(3L, true).row(4L, null).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(io.prestosql.sql.gen.JoinCompiler) RowPagesBuilder(io.prestosql.RowPagesBuilder) SetBuilderOperatorFactory(io.prestosql.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(io.prestosql.spi.Page) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) MaterializedResult(io.prestosql.testing.MaterializedResult) HashSemiJoinOperatorFactory(io.prestosql.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory) Test(org.testng.annotations.Test)

Example 20 with PlanNodeId

use of io.prestosql.spi.plan.PlanNodeId in project hetu-core by openlookeng.

the class TestHashSemiJoinOperator method testProbeSideNulls.

@Test(dataProvider = "hashEnabledValues")
public void testProbeSideNulls(boolean hashEnabled) {
    DriverContext driverContext = taskContext.addPipelineContext(0, true, true, false).addDriverContext();
    // build
    OperatorContext operatorContext = driverContext.addOperatorContext(0, new PlanNodeId("test"), ValuesOperator.class.getSimpleName());
    List<Type> buildTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, Ints.asList(0), buildTypes);
    Operator buildOperator = createValuesOperator(operatorContext, rowPagesBuilder.row(0L).row(1L).row(3L).build());
    SetBuilderOperatorFactory setBuilderOperatorFactory = new SetBuilderOperatorFactory(1, new PlanNodeId("test"), buildTypes.get(0), 0, rowPagesBuilder.getHashChannel(), 10, new JoinCompiler(createTestMetadataManager()));
    Operator setBuilderOperator = setBuilderOperatorFactory.createOperator(driverContext);
    Driver driver = Driver.createDriver(driverContext, buildOperator, setBuilderOperator);
    while (!driver.isFinished()) {
        driver.process();
    }
    // probe
    List<Type> probeTypes = ImmutableList.of(BIGINT);
    RowPagesBuilder rowPagesBuilderProbe = rowPagesBuilder(hashEnabled, Ints.asList(0), probeTypes);
    List<Page> probeInput = rowPagesBuilderProbe.row(0L).row((Object) null).row(1L).row(2L).build();
    Optional<Integer> probeHashChannel = hashEnabled ? Optional.of(probeTypes.size()) : Optional.empty();
    HashSemiJoinOperatorFactory joinOperatorFactory = new HashSemiJoinOperatorFactory(2, new PlanNodeId("test"), setBuilderOperatorFactory.getSetProvider(), rowPagesBuilderProbe.getTypes(), 0, probeHashChannel);
    // expected
    MaterializedResult expected = resultBuilder(driverContext.getSession(), concat(probeTypes, ImmutableList.of(BOOLEAN))).row(0L, true).row(null, null).row(1L, true).row(2L, false).build();
    OperatorAssertion.assertOperatorEquals(joinOperatorFactory, driverContext, probeInput, expected, hashEnabled, ImmutableList.of(probeTypes.size()));
}
Also used : JoinCompiler(io.prestosql.sql.gen.JoinCompiler) RowPagesBuilder(io.prestosql.RowPagesBuilder) SetBuilderOperatorFactory(io.prestosql.operator.SetBuilderOperator.SetBuilderOperatorFactory) Page(io.prestosql.spi.Page) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) MaterializedResult(io.prestosql.testing.MaterializedResult) HashSemiJoinOperatorFactory(io.prestosql.operator.HashSemiJoinOperator.HashSemiJoinOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

PlanNodeId (io.prestosql.spi.plan.PlanNodeId)234 Test (org.testng.annotations.Test)157 Page (io.prestosql.spi.Page)99 MaterializedResult (io.prestosql.testing.MaterializedResult)67 Type (io.prestosql.spi.type.Type)66 ImmutableList (com.google.common.collect.ImmutableList)46 RowPagesBuilder (io.prestosql.RowPagesBuilder)45 Symbol (io.prestosql.spi.plan.Symbol)45 DataSize (io.airlift.units.DataSize)39 ImmutableMap (com.google.common.collect.ImmutableMap)37 Optional (java.util.Optional)35 Split (io.prestosql.metadata.Split)31 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)29 OperatorFactory (io.prestosql.operator.OperatorFactory)27 UUID (java.util.UUID)25 JoinNode (io.prestosql.spi.plan.JoinNode)24 Metadata (io.prestosql.metadata.Metadata)23 RowExpression (io.prestosql.spi.relation.RowExpression)23 BIGINT (io.prestosql.spi.type.BigintType.BIGINT)22 SymbolStatsEstimate (io.prestosql.cost.SymbolStatsEstimate)20