use of io.trino.sql.planner.PlanNodeIdAllocator in project trino by trinodb.
the class TestEliminateCrossJoins method testDoesNotChangeOrderWithoutCrossJoin.
@Test
public void testDoesNotChangeOrderWithoutCrossJoin() {
Session session = testSessionBuilder().build();
PlanNode plan = joinNode(joinNode(values("a"), values("b"), "a", "b"), values("c"), "b", "c");
JoinGraph joinGraph = JoinGraph.buildFrom(tester().getPlannerContext(), plan, noLookup(), new PlanNodeIdAllocator(), session, createTestingTypeAnalyzer(tester().getPlannerContext()), TypeProvider.empty());
assertEquals(getJoinOrder(joinGraph), ImmutableList.of(0, 1, 2));
}
use of io.trino.sql.planner.PlanNodeIdAllocator 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.PlanNodeIdAllocator in project trino by trinodb.
the class LocalQueryRunner method createPlan.
public Plan createPlan(Session session, @Language("SQL") String sql, List<PlanOptimizer> optimizers, LogicalPlanner.Stage stage, WarningCollector warningCollector) {
PreparedQuery preparedQuery = new QueryPreparer(sqlParser).prepareQuery(session, sql);
assertFormattedSql(sqlParser, createParsingOptions(session), preparedQuery.getStatement());
PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
AnalyzerFactory analyzerFactory = createAnalyzerFactory(createQueryExplainerFactory(optimizers));
Analyzer analyzer = analyzerFactory.createAnalyzer(session, preparedQuery.getParameters(), parameterExtractor(preparedQuery.getStatement(), preparedQuery.getParameters()), warningCollector);
LogicalPlanner logicalPlanner = new LogicalPlanner(session, optimizers, new PlanSanityChecker(true), idAllocator, getPlannerContext(), new TypeAnalyzer(plannerContext, statementAnalyzerFactory), statsCalculator, costCalculator, warningCollector);
Analysis analysis = analyzer.analyze(preparedQuery.getStatement());
// make LocalQueryRunner always compute plan statistics for test purposes
return logicalPlanner.plan(analysis, stage);
}
use of io.trino.sql.planner.PlanNodeIdAllocator in project trino by trinodb.
the class QueryExplainer method getLogicalPlan.
public Plan getLogicalPlan(Session session, Statement statement, List<Expression> parameters, WarningCollector warningCollector) {
// analyze statement
Analysis analysis = analyze(session, statement, parameters, warningCollector);
PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
// plan statement
LogicalPlanner logicalPlanner = new LogicalPlanner(session, planOptimizers, idAllocator, plannerContext, new TypeAnalyzer(plannerContext, statementAnalyzerFactory), statsCalculator, costCalculator, warningCollector);
return logicalPlanner.plan(analysis, OPTIMIZED_AND_VALIDATED, true);
}
use of io.trino.sql.planner.PlanNodeIdAllocator 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