Search in sources :

Example 1 with PlanInfoExtractor

use of io.confluent.ksql.execution.plan.PlanInfoExtractor in project ksql by confluentinc.

the class EngineExecutor method planQuery.

private ExecutorPlans planQuery(final ConfiguredStatement<?> statement, final Query query, final Optional<Sink> sink, final Optional<String> withQueryId, final MetaStore metaStore) {
    final QueryEngine queryEngine = engineContext.createQueryEngine(serviceContext);
    final KsqlConfig ksqlConfig = config.getConfig(true);
    final OutputNode outputNode = QueryEngine.buildQueryLogicalPlan(query, sink, metaStore, ksqlConfig, getRowpartitionRowoffsetEnabled(ksqlConfig, statement.getSessionConfig().getOverrides()), statement.getStatementText());
    final LogicalPlanNode logicalPlan = new LogicalPlanNode(statement.getStatementText(), Optional.of(outputNode));
    final QueryId queryId = QueryIdUtil.buildId(statement.getStatement(), engineContext, engineContext.idGenerator(), outputNode, ksqlConfig.getBoolean(KsqlConfig.KSQL_CREATE_OR_REPLACE_ENABLED), withQueryId);
    if (withQueryId.isPresent() && engineContext.getQueryRegistry().getPersistentQuery(queryId).isPresent()) {
        throw new KsqlException(String.format("Query ID '%s' already exists.", queryId));
    }
    final Optional<PersistentQueryMetadata> persistentQueryMetadata = engineContext.getQueryRegistry().getPersistentQuery(queryId);
    final Optional<PlanInfo> oldPlanInfo;
    if (persistentQueryMetadata.isPresent()) {
        final ExecutionStep<?> oldPlan = persistentQueryMetadata.get().getPhysicalPlan();
        oldPlanInfo = Optional.of(oldPlan.extractPlanInfo(new PlanInfoExtractor()));
    } else {
        oldPlanInfo = Optional.empty();
    }
    final PhysicalPlan physicalPlan = queryEngine.buildPhysicalPlan(logicalPlan, config, metaStore, queryId, oldPlanInfo);
    return new ExecutorPlans(logicalPlan, physicalPlan);
}
Also used : PlanInfo(io.confluent.ksql.execution.plan.PlanInfo) KsqlBareOutputNode(io.confluent.ksql.planner.plan.KsqlBareOutputNode) KsqlStructuredDataOutputNode(io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode) OutputNode(io.confluent.ksql.planner.plan.OutputNode) PushPhysicalPlan(io.confluent.ksql.physical.scalablepush.PushPhysicalPlan) PhysicalPlan(io.confluent.ksql.physical.PhysicalPlan) PullPhysicalPlan(io.confluent.ksql.physical.pull.PullPhysicalPlan) QueryId(io.confluent.ksql.query.QueryId) KsqlConfig(io.confluent.ksql.util.KsqlConfig) LogicalPlanNode(io.confluent.ksql.planner.LogicalPlanNode) KsqlException(io.confluent.ksql.util.KsqlException) PlanInfoExtractor(io.confluent.ksql.execution.plan.PlanInfoExtractor) PersistentQueryMetadata(io.confluent.ksql.util.PersistentQueryMetadata)

Example 2 with PlanInfoExtractor

use of io.confluent.ksql.execution.plan.PlanInfoExtractor in project ksql by confluentinc.

the class PlanInfoExtractorTest method setUp.

@Before
public void setUp() {
    streamSource = new StreamSource(new ExecutionStepPropertiesV1(queryContext), "s1", formats, Optional.empty(), schema, OptionalInt.of(SystemColumns.CURRENT_PSEUDOCOLUMN_VERSION_NUMBER));
    tableSource = new TableSource(new ExecutionStepPropertiesV1(queryContext), "t1", formats, Optional.empty(), schema, SystemColumns.CURRENT_PSEUDOCOLUMN_VERSION_NUMBER, formats);
    streamSourceRepartitioned = new StreamSelectKey<>(new ExecutionStepPropertiesV1(queryContext), streamSource, ImmutableList.of(repartitionKey));
    streamAndTableJoined = new StreamTableJoin<>(new ExecutionStepPropertiesV1(queryContext), JoinType.LEFT, joinKey, formats, streamSource, tableSource);
    streamRepartitionedAndTableJoined = new StreamTableJoin<>(new ExecutionStepPropertiesV1(queryContext), JoinType.LEFT, joinKey, formats, streamSourceRepartitioned, tableSource);
    streamAndTableJoinedRepartitioned = new StreamSelectKey<>(new ExecutionStepPropertiesV1(queryContext), streamAndTableJoined, ImmutableList.of(repartitionKey));
    planInfoExtractor = new PlanInfoExtractor();
}
Also used : TableSource(io.confluent.ksql.execution.plan.TableSource) StreamSource(io.confluent.ksql.execution.plan.StreamSource) ExecutionStepPropertiesV1(io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1) PlanInfoExtractor(io.confluent.ksql.execution.plan.PlanInfoExtractor) Before(org.junit.Before)

Aggregations

PlanInfoExtractor (io.confluent.ksql.execution.plan.PlanInfoExtractor)2 ExecutionStepPropertiesV1 (io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1)1 PlanInfo (io.confluent.ksql.execution.plan.PlanInfo)1 StreamSource (io.confluent.ksql.execution.plan.StreamSource)1 TableSource (io.confluent.ksql.execution.plan.TableSource)1 PhysicalPlan (io.confluent.ksql.physical.PhysicalPlan)1 PullPhysicalPlan (io.confluent.ksql.physical.pull.PullPhysicalPlan)1 PushPhysicalPlan (io.confluent.ksql.physical.scalablepush.PushPhysicalPlan)1 LogicalPlanNode (io.confluent.ksql.planner.LogicalPlanNode)1 KsqlBareOutputNode (io.confluent.ksql.planner.plan.KsqlBareOutputNode)1 KsqlStructuredDataOutputNode (io.confluent.ksql.planner.plan.KsqlStructuredDataOutputNode)1 OutputNode (io.confluent.ksql.planner.plan.OutputNode)1 QueryId (io.confluent.ksql.query.QueryId)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 KsqlException (io.confluent.ksql.util.KsqlException)1 PersistentQueryMetadata (io.confluent.ksql.util.PersistentQueryMetadata)1 Before (org.junit.Before)1