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);
}
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));
}
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;
}
};
}
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());
}
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()));
}
Aggregations