use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.
the class PrestoSparkQueryPlanner method createQueryPlan.
public PlanAndMore createQueryPlan(Session session, PreparedQuery preparedQuery, WarningCollector warningCollector) {
PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
Analyzer analyzer = new Analyzer(session, metadata, sqlParser, accessControl, Optional.of(queryExplainer), preparedQuery.getParameters(), warningCollector);
LogicalPlanner logicalPlanner = new LogicalPlanner(false, session, optimizers.getPlanningTimeOptimizers(), idAllocator, metadata, sqlParser, statsCalculator, costCalculator, warningCollector, planChecker);
Analysis analysis = analyzer.analyze(preparedQuery.getStatement());
Plan plan = logicalPlanner.plan(analysis, OPTIMIZED_AND_VALIDATED);
List<Input> inputs = new InputExtractor(metadata, session).extractInputs(plan.getRoot());
Optional<Output> output = new OutputExtractor().extractOutput(plan.getRoot());
Optional<QueryType> queryType = getQueryType(preparedQuery.getStatement().getClass());
List<String> columnNames = ((OutputNode) plan.getRoot()).getColumnNames();
return new PlanAndMore(plan, Optional.ofNullable(analysis.getUpdateType()), columnNames, ImmutableSet.copyOf(inputs), output, queryType);
}
use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.
the class QueryExplainer method getDistributedPlan.
public SubPlan getDistributedPlan(Session session, Statement statement, List<Expression> parameters, WarningCollector warningCollector) {
PlanNodeIdAllocator idAllocator = new PlanNodeIdAllocator();
Plan plan = getLogicalPlan(session, statement, parameters, warningCollector, idAllocator);
return planFragmenter.createSubPlans(session, plan, false, idAllocator, warningCollector);
}
use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.
the class TestRemoveUnsupportedDynamicFilters method removeUnsupportedDynamicFilters.
PlanNode removeUnsupportedDynamicFilters(PlanNode root) {
return getQueryRunner().inTransaction(session -> {
// metadata.getCatalogHandle() registers the catalog for the transaction
session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
PlanNode rewrittenPlan = new RemoveUnsupportedDynamicFilters(metadata.getFunctionAndTypeManager()).optimize(root, session, TypeProvider.empty(), new PlanVariableAllocator(), new PlanNodeIdAllocator(), WarningCollector.NOOP);
new DynamicFiltersChecker().validate(rewrittenPlan, session, metadata, new SqlParser(), TypeProvider.empty(), WarningCollector.NOOP);
return rewrittenPlan;
});
}
use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.
the class TestRemoveUnsupportedDynamicFilters method setup.
@BeforeClass
public void setup() {
metadata = getQueryRunner().getMetadata();
logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(metadata.getFunctionAndTypeManager()), new FunctionResolution(metadata.getFunctionAndTypeManager()), metadata.getFunctionAndTypeManager());
builder = new PlanBuilder(getQueryRunner().getDefaultSession(), new PlanNodeIdAllocator(), metadata);
ConnectorId connectorId = getCurrentConnectorId();
TableHandle lineitemTableHandle = new TableHandle(connectorId, new TpchTableHandle("lineitem", 1.0), TestingTransactionHandle.create(), Optional.empty());
lineitemOrderKeyVariable = builder.variable("LINEITEM_OK", BIGINT);
lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeyVariable), ImmutableMap.of(lineitemOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
TableHandle ordersTableHandle = new TableHandle(connectorId, new TpchTableHandle("orders", 1.0), TestingTransactionHandle.create(), Optional.empty());
ordersOrderKeyVariable = builder.variable("ORDERS_OK", BIGINT);
ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeyVariable), ImmutableMap.of(ordersOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
}
use of com.facebook.presto.spi.plan.PlanNodeIdAllocator in project presto by prestodb.
the class TestDynamicFiltersChecker method setup.
@BeforeClass
public void setup() {
metadata = getQueryRunner().getMetadata();
logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(metadata.getFunctionAndTypeManager()), new FunctionResolution(metadata.getFunctionAndTypeManager()), metadata.getFunctionAndTypeManager());
builder = new PlanBuilder(getQueryRunner().getDefaultSession(), new PlanNodeIdAllocator(), metadata);
ConnectorId connectorId = getCurrentConnectorId();
TableHandle lineitemTableHandle = new TableHandle(connectorId, new TpchTableHandle("lineitem", 1.0), TestingTransactionHandle.create(), Optional.empty());
lineitemOrderKeyVariable = builder.variable("LINEITEM_OK", BIGINT);
lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeyVariable), ImmutableMap.of(lineitemOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
TableHandle ordersTableHandle = new TableHandle(connectorId, new TpchTableHandle("orders", 1.0), TestingTransactionHandle.create(), Optional.empty());
ordersOrderKeyVariable = builder.variable("ORDERS_OK", BIGINT);
ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeyVariable), ImmutableMap.of(ordersOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
}
Aggregations