Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public Map<String, Object> apply(OverAllState state) throws Exception {

// Get necessary input parameters
Plan plan = PlanProcessUtil.getPlan(state);
ExecutionStep executionStep = PlanProcessUtil.getCurrentExecutionStep(state);
ExecutionStep executionStep = PlanProcessUtil.getCurrentExecutionStep(plan,
PlanProcessUtil.getCurrentStepNumber(state));
ExecutionStep.ToolParameters toolParameters = executionStep.getToolParameters();

// Execute business logic first - determine what needs to be regenerated
Expand Down Expand Up @@ -219,11 +220,11 @@ public Flux<String> get() {
roundRef.get())
.collect(StringBuilder::new, StringBuilder::append)
.map(StringBuilder::toString)
.flatMapMany(sql -> Flux.just(nl2SqlService.sqlTrim(sql)).expand(newSql -> {
.flatMapMany(sql -> Flux.just(nl2SqlService.sqlTrim(sql)).expandDeep(newSql -> {
if (checkSqlFunc.apply(newSql) || roundRef.getAndIncrement() > MAX_OPTIMIZATION_ROUNDS) {
String bestSql = bestSqlRef.get();
bestSqlConsumer.accept(bestSql);
return Flux.just(bestSql);
return Flux.empty();
}
else {
return this.get();
Expand All @@ -243,7 +244,7 @@ public Flux<String> get() {
if (checkSqlFunc.apply(newSql) || roundRef.getAndIncrement() > MAX_OPTIMIZATION_ROUNDS) {
String bestSql = bestSqlRef.get();
bestSqlConsumer.accept(bestSql);
return Flux.just(bestSql);
return Flux.empty();
}
else {
return reGenerateSupplier.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,18 @@ private PlanProcessUtil() {
public static ExecutionStep getCurrentExecutionStep(OverAllState state) {
Plan plan = getPlan(state);
int currentStep = getCurrentStepNumber(state);
return getCurrentExecutionStep(plan, currentStep);
}

/**
* Get the current execution step from the plan
* @param plan the plan object
* @param currentStep current step
* @return the current execution step
* @throws IllegalStateException if plan output is empty, plan parsing fails, or step
* index is out of range
*/
public static ExecutionStep getCurrentExecutionStep(Plan plan, Integer currentStep) {
List<ExecutionStep> executionPlan = plan.getExecutionPlan();
if (executionPlan == null || executionPlan.isEmpty()) {
throw new IllegalStateException("执行计划为空");
Expand Down
Loading