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);
}
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();
}
Aggregations