use of com.facebook.presto.sql.planner.PlanVariableAllocator in project presto by prestodb.
the class TestPlanRemoteProjections method testLocalOnly.
@Test
void testLocalOnly() {
PlanBuilder planBuilder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), getMetadata());
planBuilder.variable("x", INTEGER);
planBuilder.variable("y", INTEGER);
PlanRemotePojections rule = new PlanRemotePojections(getFunctionAndTypeManager());
List<ProjectionContext> rewritten = rule.planRemoteAssignments(Assignments.builder().put(planBuilder.variable("a"), planBuilder.rowExpression("abs(x) + abs(y)")).put(planBuilder.variable("b", BOOLEAN), planBuilder.rowExpression("x is null and y is null")).build(), new PlanVariableAllocator(planBuilder.getTypes().allVariables()));
assertEquals(rewritten.size(), 1);
assertEquals(rewritten.get(0).getProjections().size(), 2);
}
use of com.facebook.presto.sql.planner.PlanVariableAllocator in project presto by prestodb.
the class TestPlanRemoteProjections method testRemoteAndLocal.
@Test
void testRemoteAndLocal() {
PlanBuilder planBuilder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), getMetadata());
planBuilder.variable("x", INTEGER);
planBuilder.variable("y", INTEGER);
PlanRemotePojections rule = new PlanRemotePojections(getFunctionAndTypeManager());
List<ProjectionContext> rewritten = rule.planRemoteAssignments(Assignments.builder().put(planBuilder.variable("a"), planBuilder.rowExpression("unittest.memory.remote_foo(x, y + unittest.memory.remote_foo(x))")).put(planBuilder.variable("b"), planBuilder.rowExpression("abs(x)")).put(planBuilder.variable("c"), planBuilder.rowExpression("abs(unittest.memory.remote_foo())")).put(planBuilder.variable("d"), planBuilder.rowExpression("unittest.memory.remote_foo(x + y, abs(x))")).build(), new PlanVariableAllocator(planBuilder.getTypes().allVariables()));
assertEquals(rewritten.size(), 4);
assertEquals(rewritten.get(3).getProjections().size(), 4);
}
use of com.facebook.presto.sql.planner.PlanVariableAllocator in project presto by prestodb.
the class TestJoinEnumerator method createContext.
private Rule.Context createContext() {
PlanNodeIdAllocator planNodeIdAllocator = new PlanNodeIdAllocator();
PlanVariableAllocator variableAllocator = new PlanVariableAllocator();
CachingStatsProvider statsProvider = new CachingStatsProvider(queryRunner.getStatsCalculator(), Optional.empty(), noLookup(), queryRunner.getDefaultSession(), variableAllocator.getTypes());
CachingCostProvider costProvider = new CachingCostProvider(queryRunner.getCostCalculator(), statsProvider, Optional.empty(), queryRunner.getDefaultSession());
return new Rule.Context() {
@Override
public Lookup getLookup() {
return noLookup();
}
@Override
public PlanNodeIdAllocator getIdAllocator() {
return planNodeIdAllocator;
}
@Override
public PlanVariableAllocator getVariableAllocator() {
return variableAllocator;
}
@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 com.facebook.presto.sql.planner.PlanVariableAllocator in project presto by prestodb.
the class TestDruidPlanOptimizer method getOptimizedPlan.
private PlanNode getOptimizedPlan(PlanBuilder planBuilder, PlanNode originalPlan) {
DruidQueryGenerator druidQueryGenerator = new DruidQueryGenerator(functionAndTypeManager, functionAndTypeManager, standardFunctionResolution);
DruidPlanOptimizer optimizer = new DruidPlanOptimizer(druidQueryGenerator, functionAndTypeManager, new RowExpressionDeterminismEvaluator(functionAndTypeManager), functionAndTypeManager, standardFunctionResolution);
return optimizer.optimize(originalPlan, defaultSessionHolder.getConnectorSession(), new PlanVariableAllocator(), planBuilder.getIdAllocator());
}
use of com.facebook.presto.sql.planner.PlanVariableAllocator in project presto by prestodb.
the class OptimizerAssert method matches.
public void matches(PlanMatchPattern pattern) {
PlanNode actual = optimizer.optimize(plan, session, types, new PlanVariableAllocator(), idAllocator, WarningCollector.NOOP);
if (!ImmutableSet.copyOf(plan.getOutputVariables()).equals(ImmutableSet.copyOf(actual.getOutputVariables()))) {
fail(String.format("%s: output schema of transformed and original plans are not equivalent\n" + "\texpected: %s\n" + "\tactual: %s", optimizer.getClass().getName(), plan.getOutputVariables(), actual.getOutputVariables()));
}
inTransaction(session -> {
assertPlan(session, metadata, statsCalculator, new Plan(actual, types, StatsAndCosts.empty()), pattern);
return null;
});
}
Aggregations