@@ -195,7 +195,7 @@ public void execute(
195
195
196
196
// we have no sub plans, so we can just execute the given plan
197
197
if (subplans == null || subplans .size () == 0 ) {
198
- executePlan (sessionId , rootTask , physicalPlan , configuration , foldContext , execInfo , listener , null );
198
+ executePlan (sessionId , rootTask , physicalPlan , configuration , foldContext , execInfo , null , listener , null );
199
199
return ;
200
200
}
201
201
@@ -220,7 +220,7 @@ public void execute(
220
220
var finalListener = ActionListener .runBefore (listener , () -> exchangeService .removeExchangeSourceHandler (sessionId ));
221
221
var computeContext = new ComputeContext (
222
222
mainSessionId ,
223
- "single " ,
223
+ "main.final " ,
224
224
LOCAL_CLUSTER ,
225
225
List .of (),
226
226
configuration ,
@@ -244,22 +244,33 @@ public void execute(
244
244
) {
245
245
runCompute (rootTask , computeContext , finalMainPlan , localListener .acquireCompute ());
246
246
247
- for (PhysicalPlan subplan : subplans ) {
247
+ for (int i = 0 ; i < subplans .size (); i ++) {
248
+ var subplan = subplans .get (i );
248
249
var childSessionId = newChildSession (sessionId );
249
250
ExchangeSinkHandler exchangeSink = exchangeService .createSinkHandler (childSessionId , queryPragmas .exchangeBufferSize ());
250
251
// funnel sub plan pages into the main plan exchange source
251
252
mainExchangeSource .addRemoteSink (exchangeSink ::fetchPageAsync , true , () -> {}, 1 , ActionListener .noop ());
252
253
var subPlanListener = localListener .acquireCompute ();
253
254
254
- executePlan (childSessionId , rootTask , subplan , configuration , foldContext , execInfo , ActionListener .wrap (result -> {
255
- exchangeSink .addCompletionListener (
256
- ActionListener .running (() -> { exchangeService .finishSinkHandler (childSessionId , null ); })
257
- );
258
- subPlanListener .onResponse (result .completionInfo ());
259
- }, e -> {
260
- exchangeService .finishSinkHandler (childSessionId , e );
261
- subPlanListener .onFailure (e );
262
- }), () -> exchangeSink .createExchangeSink (() -> {}));
255
+ executePlan (
256
+ childSessionId ,
257
+ rootTask ,
258
+ subplan ,
259
+ configuration ,
260
+ foldContext ,
261
+ execInfo ,
262
+ "subplan-" + i ,
263
+ ActionListener .wrap (result -> {
264
+ exchangeSink .addCompletionListener (
265
+ ActionListener .running (() -> { exchangeService .finishSinkHandler (childSessionId , null ); })
266
+ );
267
+ subPlanListener .onResponse (result .completionInfo ());
268
+ }, e -> {
269
+ exchangeService .finishSinkHandler (childSessionId , e );
270
+ subPlanListener .onFailure (e );
271
+ }),
272
+ () -> exchangeSink .createExchangeSink (() -> {})
273
+ );
263
274
}
264
275
}
265
276
}
@@ -272,6 +283,7 @@ public void executePlan(
272
283
Configuration configuration ,
273
284
FoldContext foldContext ,
274
285
EsqlExecutionInfo execInfo ,
286
+ String profileQualifier ,
275
287
ActionListener <Result > listener ,
276
288
Supplier <ExchangeSink > exchangeSinkSupplier
277
289
) {
@@ -309,7 +321,7 @@ public void executePlan(
309
321
}
310
322
var computeContext = new ComputeContext (
311
323
newChildSession (sessionId ),
312
- "single" ,
324
+ profileDescription ( profileQualifier , "single" ) ,
313
325
LOCAL_CLUSTER ,
314
326
List .of (),
315
327
configuration ,
@@ -395,7 +407,7 @@ public void executePlan(
395
407
rootTask ,
396
408
new ComputeContext (
397
409
sessionId ,
398
- "final" ,
410
+ profileDescription ( profileQualifier , "final" ) ,
399
411
LOCAL_CLUSTER ,
400
412
List .of (),
401
413
configuration ,
@@ -611,6 +623,10 @@ String newChildSession(String session) {
611
623
return session + "/" + childSessionIdGenerator .incrementAndGet ();
612
624
}
613
625
626
+ String profileDescription (String qualifier , String label ) {
627
+ return qualifier == null ? label : qualifier + "." + label ;
628
+ }
629
+
614
630
Runnable cancelQueryOnFailure (CancellableTask task ) {
615
631
return new RunOnce (() -> {
616
632
LOGGER .debug ("cancelling ESQL task {} on failure" , task );
0 commit comments