Search in sources :

Example 1 with PlanNodeIdAllocator

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

the class TestExternalFunctionPushDownChecker method setup.

@BeforeClass
public void setup() {
    planSymbolAllocator = new PlanSymbolAllocator();
    columnA = planSymbolAllocator.newSymbol("a", DOUBLE);
    columnB = planSymbolAllocator.newSymbol("b", DOUBLE);
    sumCall = call("sum", SUM, DOUBLE, ImmutableList.of(VariableReferenceSymbolConverter.toVariableReference(columnA, DOUBLE)));
    externalFooCall1 = new CallExpression("jdbc.v1.foo", EXTERNAL_FOO, DOUBLE, ImmutableList.of());
    externalFooCall2 = new CallExpression("jdbc.v1.foo2", EXTERNAL_FOO, DOUBLE, ImmutableList.of());
    metadata = getQueryRunner().getMetadata();
    builder = new PlanBuilder(new PlanNodeIdAllocator(), metadata);
}
Also used : PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) CallExpression(io.prestosql.spi.relation.CallExpression) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with PlanNodeIdAllocator

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

the class TestCardinalityExtractorPlanVisitor method testAggregation.

@Test
public void testAggregation() {
    PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata());
    Symbol symbol = planBuilder.symbol("symbol");
    ColumnHandle columnHandle = new TestingColumnHandle("column");
    // single default aggregation
    assertEquals(extractCardinality(planBuilder.aggregation(builder -> builder.singleGroupingSet().source(planBuilder.values(10)))), Range.singleton(1L));
    // multiple grouping sets with default aggregation with source that produces arbitrary number of rows
    assertEquals(extractCardinality(planBuilder.aggregation(builder -> builder.groupingSets(AggregationNode.groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(planBuilder.tableScan(ImmutableList.of(symbol), ImmutableMap.of(symbol, columnHandle))))), Range.atLeast(1L));
    // multiple grouping sets with default aggregation with source that produces exact number of rows
    assertEquals(extractCardinality(planBuilder.aggregation(builder -> builder.groupingSets(AggregationNode.groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(planBuilder.values(10, symbol)))), Range.closed(1L, 10L));
    // multiple grouping sets with default aggregation with source that produces no rows
    assertEquals(extractCardinality(planBuilder.aggregation(builder -> builder.groupingSets(AggregationNode.groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))).source(planBuilder.values(0, symbol)))), Range.singleton(1L));
    // single non-default aggregation with source that produces arbitrary number of rows
    assertEquals(extractCardinality(planBuilder.aggregation(builder -> builder.singleGroupingSet(symbol).source(planBuilder.tableScan(ImmutableList.of(symbol), ImmutableMap.of(symbol, columnHandle))))), Range.atLeast(0L));
    // single non-default aggregation with source that produces at least single row
    assertEquals(extractCardinality(planBuilder.aggregation(builder -> builder.singleGroupingSet(symbol).source(planBuilder.values(10, symbol)))), Range.closed(1L, 10L));
    // single non-default aggregation with source that produces no rows
    assertEquals(extractCardinality(planBuilder.aggregation(builder -> builder.singleGroupingSet(symbol).source(planBuilder.values(0, symbol)))), Range.singleton(0L));
}
Also used : TestingColumnHandle(io.prestosql.spi.connector.TestingColumnHandle) ColumnHandle(io.prestosql.spi.connector.ColumnHandle) TestingColumnHandle(io.prestosql.spi.connector.TestingColumnHandle) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) Symbol(io.prestosql.spi.plan.Symbol) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Example 3 with PlanNodeIdAllocator

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

the class TestJoinEnumerator method createContext.

private Rule.Context createContext() {
    PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator();
    Map<Symbol, Type> symbols = new HashMap<>();
    symbols.put(new Symbol("A1"), BIGINT);
    symbols.put(new Symbol("B1"), BIGINT);
    PlanSymbolAllocator planSymbolAllocator = new PlanSymbolAllocator(symbols);
    CachingStatsProvider statsProvider = new CachingStatsProvider(queryRunner.getStatsCalculator(), Optional.empty(), noLookup(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
    CachingCostProvider costProvider = new CachingCostProvider(queryRunner.getCostCalculator(), statsProvider, Optional.empty(), queryRunner.getDefaultSession(), planSymbolAllocator.getTypes());
    return new Rule.Context() {

        @Override
        public Lookup getLookup() {
            return noLookup();
        }

        @Override
        public PlanNodeIdAllocator getIdAllocator() {
            return planNodeIdAllocator;
        }

        @Override
        public PlanSymbolAllocator getSymbolAllocator() {
            return planSymbolAllocator;
        }

        @Override
        public Session getSession() {
            return queryRunner.getDefaultSession();
        }

        @Override
        public StatsProvider getStatsProvider() {
            return statsProvider;
        }

        @Override
        public CostProvider getCostProvider() {
            return costProvider;
        }

        @Override
        public void checkTimeoutNotExhausted() {
        }

        @Override
        public WarningCollector getWarningCollector() {
            return WarningCollector.NOOP;
        }
    };
}
Also used : Type(io.prestosql.spi.type.Type) CachingStatsProvider(io.prestosql.cost.CachingStatsProvider) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) HashMap(java.util.HashMap) Symbol(io.prestosql.spi.plan.Symbol) CachingCostProvider(io.prestosql.cost.CachingCostProvider) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator)

Example 4 with PlanNodeIdAllocator

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

the class TestUtil method createExchangePlanFragment.

private static PlanFragment createExchangePlanFragment(RowExpression expr) {
    Symbol testSymbol = new Symbol("a");
    Map<Symbol, ColumnHandle> scanAssignments = ImmutableMap.<Symbol, ColumnHandle>builder().put(testSymbol, new TestingMetadata.TestingColumnHandle("a")).build();
    Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(testSymbol)));
    TableScanNode tableScanNode = new TableScanNode(new PlanNodeId(UUID.randomUUID().toString()), makeTableHandle(TupleDomain.none()), ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.none(), Optional.empty(), ReuseExchangeOperator.STRATEGY.REUSE_STRATEGY_DEFAULT, new UUID(0, 0), 0, false);
    PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata());
    FilterNode filterNode = planBuilder.filter(expr, tableScanNode);
    PlanNode planNode = new LimitNode(new PlanNodeId("limit"), filterNode, 1, false);
    ImmutableMap.Builder<Symbol, Type> types = ImmutableMap.builder();
    for (Symbol symbol : planNode.getOutputSymbols()) {
        types.put(symbol, VARCHAR);
    }
    return new PlanFragment(new PlanFragmentId("limit_fragment_id"), planNode, types.build(), SOURCE_DISTRIBUTION, ImmutableList.of(planNode.getId()), new PartitioningScheme(Partitioning.create(SINGLE_DISTRIBUTION, ImmutableList.of()), planNode.getOutputSymbols()), ungroupedExecution(), StatsAndCosts.empty(), Optional.empty(), Optional.empty(), Optional.empty());
}
Also used : ColumnHandle(io.prestosql.spi.connector.ColumnHandle) Symbol(io.prestosql.spi.plan.Symbol) PartitioningScheme(io.prestosql.sql.planner.PartitioningScheme) FilterNode(io.prestosql.spi.plan.FilterNode) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) ImmutableMap(com.google.common.collect.ImmutableMap) PlanFragment(io.prestosql.sql.planner.PlanFragment) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) Type(io.prestosql.spi.type.Type) PlanNode(io.prestosql.spi.plan.PlanNode) TableScanNode(io.prestosql.spi.plan.TableScanNode) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) LimitNode(io.prestosql.spi.plan.LimitNode) PlanFragmentId(io.prestosql.sql.planner.plan.PlanFragmentId) UUID(java.util.UUID)

Example 5 with PlanNodeIdAllocator

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

the class TestSchedulingOrderVisitor method testIndexJoinOrder.

@Test
public void testIndexJoinOrder() {
    PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata());
    TableScanNode a = planBuilder.tableScan(emptyList(), emptyMap());
    TableScanNode b = planBuilder.tableScan(emptyList(), emptyMap());
    List<PlanNodeId> order = scheduleOrder(planBuilder.indexJoin(IndexJoinNode.Type.INNER, a, b));
    assertEquals(order, ImmutableList.of(b.getId(), a.getId()));
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) TableScanNode(io.prestosql.spi.plan.TableScanNode) PlanNodeIdAllocator(io.prestosql.spi.plan.PlanNodeIdAllocator) PlanBuilder(io.prestosql.sql.planner.iterative.rule.test.PlanBuilder) Test(org.testng.annotations.Test)

Aggregations

PlanNodeIdAllocator (io.prestosql.spi.plan.PlanNodeIdAllocator)20 Symbol (io.prestosql.spi.plan.Symbol)11 PlanBuilder (io.prestosql.sql.planner.iterative.rule.test.PlanBuilder)11 TableScanNode (io.prestosql.spi.plan.TableScanNode)8 PlanNode (io.prestosql.spi.plan.PlanNode)7 Test (org.testng.annotations.Test)6 Session (io.prestosql.Session)5 TableHandle (io.prestosql.spi.metadata.TableHandle)5 PlanSymbolAllocator (io.prestosql.sql.planner.PlanSymbolAllocator)5 TypeAnalyzer (io.prestosql.sql.planner.TypeAnalyzer)5 ColumnHandle (io.prestosql.spi.connector.ColumnHandle)4 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)4 Rule (io.prestosql.sql.planner.iterative.Rule)4 List (java.util.List)4 Map (java.util.Map)4 Optional (java.util.Optional)4 Set (java.util.Set)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 FilterNode (io.prestosql.spi.plan.FilterNode)3 ImmutableList (com.google.common.collect.ImmutableList)2