use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder 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.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestPruneAggregationColumns method buildProjectedAggregation.
private ProjectNode buildProjectedAggregation(PlanBuilder planBuilder, Predicate<VariableReferenceExpression> projectionFilter) {
VariableReferenceExpression a = planBuilder.variable("a");
VariableReferenceExpression b = planBuilder.variable("b");
VariableReferenceExpression key = planBuilder.variable("key");
return planBuilder.project(identityAssignmentsAsSymbolReferences(ImmutableList.of(a, b).stream().filter(projectionFilter).collect(toImmutableSet())), planBuilder.aggregation(aggregationBuilder -> aggregationBuilder.source(planBuilder.values(key)).singleGroupingSet(key).addAggregation(a, planBuilder.expression("count()"), ImmutableList.of()).addAggregation(b, planBuilder.expression("count()"), ImmutableList.of())));
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestJoinEnumerator method testDoesNotCreateJoinWhenPartitionedOnCrossJoin.
@Test
public void testDoesNotCreateJoinWhenPartitionedOnCrossJoin() {
PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
PlanBuilder p = new PlanBuilder(TEST_SESSION, idAllocator, queryRunner.getMetadata());
VariableReferenceExpression a1 = p.variable("A1");
VariableReferenceExpression b1 = p.variable("B1");
MultiJoinNode multiJoinNode = new MultiJoinNode(new LinkedHashSet<>(ImmutableList.of(p.values(a1), p.values(b1))), TRUE_CONSTANT, ImmutableList.of(a1, b1));
JoinEnumerator joinEnumerator = new JoinEnumerator(new CostComparator(1, 1, 1), multiJoinNode.getFilter(), createContext(), determinismEvaluator, functionResolution, metadata);
JoinEnumerationResult actual = joinEnumerator.createJoinAccordingToPartitioning(multiJoinNode.getSources(), multiJoinNode.getOutputVariables(), ImmutableSet.of(0));
assertFalse(actual.getPlanNode().isPresent());
assertEquals(actual.getCost(), PlanCostEstimate.infinite());
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestDruidQueryGenerator method testGroupByPushdown.
@Test
public void testGroupByPushdown() {
PlanNode justScan = buildPlan(planBuilder -> tableScan(planBuilder, druidTable, regionId, secondsSinceEpoch, city, fare));
testDQL(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(justScan).singleGroupingSet(variable("city"), variable("region.id"), variable("secondssinceepoch")).addAggregation(variable("totalfare"), getRowExpression("sum(\"fare\")", defaultSessionHolder))), "SELECT \"city\", \"region.Id\", \"secondsSinceEpoch\", sum(fare) FROM \"realtimeOnly\" GROUP BY \"city\", \"region.Id\", \"secondsSinceEpoch\"");
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestDruidQueryGenerator method testDistinctCountPushdown.
@Test
public void testDistinctCountPushdown() {
PlanNode justScan = buildPlan(planBuilder -> tableScan(planBuilder, druidTable, regionId, secondsSinceEpoch, city, fare));
PlanNode distinctAggregation = buildPlan(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(justScan).singleGroupingSet(variable("region.id"))));
testDQL(planBuilder -> planBuilder.aggregation(aggBuilder -> aggBuilder.source(distinctAggregation).globalGrouping().addAggregation(variable("region.id"), getRowExpression("count(\"region.id\")", defaultSessionHolder))), "SELECT count ( distinct \"region.Id\") FROM \"realtimeOnly\"");
}
Aggregations