use of io.trino.sql.planner.iterative.rule.test.PlanBuilder in project trino by trinodb.
the class TestPruneAggregationColumns method buildProjectedAggregation.
private ProjectNode buildProjectedAggregation(PlanBuilder planBuilder, Predicate<Symbol> projectionFilter) {
Symbol a = planBuilder.symbol("a");
Symbol b = planBuilder.symbol("b");
Symbol key = planBuilder.symbol("key");
return planBuilder.project(Assignments.identity(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 io.trino.sql.planner.iterative.rule.test.PlanBuilder in project trino by trinodb.
the class StatsCalculatorTester method assertStatsFor.
public StatsCalculatorAssertion assertStatsFor(Session session, Function<PlanBuilder, PlanNode> planProvider) {
PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), metadata, session);
PlanNode planNode = planProvider.apply(planBuilder);
return new StatsCalculatorAssertion(statsCalculator, session, planNode, planBuilder.getTypes());
}
use of io.trino.sql.planner.iterative.rule.test.PlanBuilder in project trino by trinodb.
the class TestSchedulingOrderVisitor method testJoinOrder.
@Test
public void testJoinOrder() {
PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata(), TEST_SESSION);
TableScanNode a = planBuilder.tableScan(emptyList(), emptyMap());
TableScanNode b = planBuilder.tableScan(emptyList(), emptyMap());
List<PlanNodeId> order = scheduleOrder(planBuilder.join(JoinNode.Type.INNER, a, b));
assertEquals(order, ImmutableList.of(b.getId(), a.getId()));
}
use of io.trino.sql.planner.iterative.rule.test.PlanBuilder in project trino by trinodb.
the class TestSchedulingOrderVisitor method testSemiJoinOrder.
@Test
public void testSemiJoinOrder() {
PlanBuilder planBuilder = new PlanBuilder(new PlanNodeIdAllocator(), dummyMetadata(), TEST_SESSION);
Symbol sourceJoin = planBuilder.symbol("sourceJoin");
TableScanNode a = planBuilder.tableScan(ImmutableList.of(sourceJoin), ImmutableMap.of(sourceJoin, new TestingColumnHandle("sourceJoin")));
Symbol filteringSource = planBuilder.symbol("filteringSource");
TableScanNode b = planBuilder.tableScan(ImmutableList.of(filteringSource), ImmutableMap.of(filteringSource, new TestingColumnHandle("filteringSource")));
List<PlanNodeId> order = scheduleOrder(planBuilder.semiJoin(sourceJoin, filteringSource, planBuilder.symbol("semiJoinOutput"), Optional.empty(), Optional.empty(), a, b));
assertEquals(order, ImmutableList.of(b.getId(), a.getId()));
}
use of io.trino.sql.planner.iterative.rule.test.PlanBuilder in project trino by trinodb.
the class TestDynamicFiltersChecker method setup.
@BeforeClass
public void setup() {
plannerContext = getQueryRunner().getPlannerContext();
metadata = plannerContext.getMetadata();
builder = new PlanBuilder(new PlanNodeIdAllocator(), metadata, TEST_SESSION);
CatalogName catalogName = getCurrentConnectorId();
TableHandle lineitemTableHandle = new TableHandle(catalogName, new TpchTableHandle("sf1", "lineitem", 1.0), TestingTransactionHandle.create());
lineitemOrderKeySymbol = builder.symbol("LINEITEM_OK", BIGINT);
lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeySymbol), ImmutableMap.of(lineitemOrderKeySymbol, new TpchColumnHandle("orderkey", BIGINT)));
TableHandle ordersTableHandle = new TableHandle(catalogName, new TpchTableHandle("sf1", "orders", 1.0), TestingTransactionHandle.create());
ordersOrderKeySymbol = builder.symbol("ORDERS_OK", BIGINT);
ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeySymbol), ImmutableMap.of(ordersOrderKeySymbol, new TpchColumnHandle("orderkey", BIGINT)));
}
Aggregations