use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestMemo method testEvictStatsOnReplace.
@Test
public void testEvictStatsOnReplace() {
PlanNode y = node();
PlanNode x = node(y);
Memo memo = new Memo(idAllocator, x);
int xGroup = memo.getRootGroup();
int yGroup = getChildGroup(memo, memo.getRootGroup());
PlanNodeStatsEstimate xStats = PlanNodeStatsEstimate.builder().setOutputRowCount(42).build();
PlanNodeStatsEstimate yStats = PlanNodeStatsEstimate.builder().setOutputRowCount(55).build();
memo.storeStats(yGroup, yStats);
memo.storeStats(xGroup, xStats);
assertEquals(memo.getStats(yGroup), Optional.of(yStats));
assertEquals(memo.getStats(xGroup), Optional.of(xStats));
memo.replace(yGroup, node(), "rule");
assertEquals(memo.getStats(yGroup), Optional.empty());
assertEquals(memo.getStats(xGroup), Optional.empty());
}
use of io.prestosql.spi.plan.PlanNode 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.PlanNode in project hetu-core by openlookeng.
the class PlanAssert method assertPlan.
public static void assertPlan(Session session, Metadata metadata, StatsProvider statsProvider, Plan actual, Lookup lookup, PlanMatchPattern pattern) {
MatchResult matches = actual.getRoot().accept(new PlanMatchingVisitor(session, metadata, statsProvider, lookup), pattern);
if (!matches.isMatch()) {
String formattedPlan = textLogicalPlan(actual.getRoot(), actual.getTypes(), metadata, StatsAndCosts.empty(), session, 0, false);
PlanNode resolvedPlan = resolveGroupReferences(actual.getRoot(), lookup);
String resolvedFormattedPlan = textLogicalPlan(resolvedPlan, actual.getTypes(), metadata, StatsAndCosts.empty(), session, 0, false);
throw new AssertionError(format("Plan does not match, expected [\n\n%s\n] but found [\n\n%s\n] which resolves to [\n\n%s\n]", pattern, formattedPlan, resolvedFormattedPlan));
}
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestTypeValidator method testInvalidProject.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "type of symbol 'expr(_[0-9]+)?' is expected to be bigint, but the actual type is integer")
public void testInvalidProject() {
Expression expression1 = new Cast(toSymbolReference(columnB), StandardTypes.INTEGER);
Expression expression2 = new Cast(toSymbolReference(columnA), StandardTypes.INTEGER);
Assignments assignments = Assignments.builder().put(planSymbolAllocator.newSymbol(expression1, BIGINT), // should be INTEGER
castToRowExpression(expression1)).put(planSymbolAllocator.newSymbol(expression1, INTEGER), castToRowExpression(expression2)).build();
PlanNode node = new ProjectNode(newId(), baseTableScan, assignments);
assertTypesValid(node);
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestTypeValidator method testValidWindow.
@Test
public void testValidWindow() {
Symbol windowSymbol = planSymbolAllocator.newSymbol("sum", DOUBLE);
FunctionHandle functionHandle = FUNCTION_MANAGER.lookupFunction("sum", fromTypes(DOUBLE));
WindowNode.Frame frame = new WindowNode.Frame(WindowFrameType.RANGE, FrameBoundType.UNBOUNDED_PRECEDING, Optional.empty(), FrameBoundType.UNBOUNDED_FOLLOWING, Optional.empty(), Optional.empty(), Optional.empty());
WindowNode.Function function = new WindowNode.Function(call("sum", functionHandle, DOUBLE, ImmutableList.of(VariableReferenceSymbolConverter.toVariableReference(columnC, DOUBLE))), ImmutableList.of(VariableReferenceSymbolConverter.toVariableReference(columnC, DOUBLE)), frame);
WindowNode.Specification specification = new WindowNode.Specification(ImmutableList.of(), Optional.empty());
PlanNode node = new WindowNode(newId(), baseTableScan, specification, ImmutableMap.of(windowSymbol, function), Optional.empty(), ImmutableSet.of(), 0);
assertTypesValid(node);
}
Aggregations