use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class RuleAssert method matches.
public void matches(PlanMatchPattern pattern) {
RuleApplication ruleApplication = applyRule();
TypeProvider typeProvider = ruleApplication.types;
if (!ruleApplication.wasRuleApplied()) {
fail(format("%s did not fire for:\n%s", rule.getClass().getName(), formatPlan(plan, typeProvider)));
}
PlanNode actual = ruleApplication.getTransformedPlan();
if (actual == plan) {
// plans are not comparable, so we can only ensure they are not the same instance
fail(format("%s: rule fired but return the original plan:\n%s", rule.getClass().getName(), formatPlan(plan, typeProvider)));
}
if (!ImmutableSet.copyOf(plan.getOutputSymbols()).equals(ImmutableSet.copyOf(actual.getOutputSymbols()))) {
fail(format("%s: output schema of transformed and original plans are not equivalent\n" + "\texpected: %s\n" + "\tactual: %s", rule.getClass().getName(), plan.getOutputSymbols(), actual.getOutputSymbols()));
}
inTransaction(session -> {
assertPlan(session, metadata, ruleApplication.statsProvider, new Plan(actual, typeProvider, StatsAndCosts.empty()), ruleApplication.lookup, pattern);
return null;
});
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class RuleAssert method applyRule.
private RuleApplication applyRule() {
PlanSymbolAllocator planSymbolAllocator = new PlanSymbolAllocator(types.allTypes());
Memo memo = new Memo(idAllocator, plan);
Lookup lookup = Lookup.from(planNode -> Stream.of(memo.resolve(planNode)));
PlanNode memoRoot = memo.getNode(memo.getRootGroup());
return inTransaction(session -> applyRule(rule, memoRoot, ruleContext(statsCalculator, costCalculator, planSymbolAllocator, memo, lookup, session)));
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestVerifyOnlyOneOutputNode method testValidateSuccessful.
@Test
public void testValidateSuccessful() {
// random seemingly valid plan
PlanNode root = new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestVerifyOnlyOneOutputNode method testValidateFailed.
@Test(expectedExceptions = IllegalStateException.class)
public void testValidateFailed() {
// random plan with 2 output nodes
PlanNode root = new OutputNode(idAllocator.getNextId(), new ExplainAnalyzeNode(idAllocator.getNextId(), new OutputNode(idAllocator.getNextId(), new ProjectNode(idAllocator.getNextId(), new ValuesNode(idAllocator.getNextId(), ImmutableList.of(), ImmutableList.of()), Assignments.of()), ImmutableList.of(), ImmutableList.of()), new Symbol("a"), false), ImmutableList.of(), ImmutableList.of());
new VerifyOnlyOneOutputNode().validate(root, null, null, null, null, WarningCollector.NOOP);
}
use of io.prestosql.spi.plan.PlanNode in project hetu-core by openlookeng.
the class TestExternalFunctionPushDownChecker method testWindowNodeWithExternalCall.
@Test(expectedExceptions = ExternalFunctionPushDownChecker.IllegalExternalFunctionUsageException.class, expectedExceptionsMessageRegExp = "The external function jdbc.v1.foo does not support to push down to data source for this query.")
public void testWindowNodeWithExternalCall() {
WindowNode.Frame frame = new WindowNode.Frame(Types.WindowFrameType.RANGE, UNBOUNDED_PRECEDING, Optional.empty(), CURRENT_ROW, Optional.empty(), Optional.empty(), Optional.empty());
PlanNode root = builder.window(new WindowNode.Specification(ImmutableList.of(columnA), Optional.empty()), ImmutableMap.of(columnB, new WindowNode.Function(externalFooCall1, ImmutableList.of(), frame)), builder.values(columnA));
validatePlan(root);
}
Aggregations