diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java index d1a099fc406bc..e30b3db4da84f 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/ComputeService.java @@ -149,8 +149,13 @@ public void execute( var concreteIndices = PlannerUtils.planConcreteIndices(physicalPlan); QueryPragmas queryPragmas = configuration.pragmas(); - - if (concreteIndices.isEmpty()) { + if (dataNodePlan == null) { + if (concreteIndices.isEmpty() == false) { + String error = "expected no concrete indices without data node plan; got " + concreteIndices; + assert false : error; + listener.onFailure(new IllegalStateException(error)); + return; + } var computeContext = new ComputeContext(sessionId, List.of(), configuration, null, null); runCompute( rootTask, @@ -160,6 +165,12 @@ public void execute( ); return; } + if (concreteIndices.isEmpty()) { + var error = "expected concrete indices with data node plan but got empty; data node plan " + dataNodePlan; + assert false : error; + listener.onFailure(new IllegalStateException(error)); + return; + } QueryBuilder requestFilter = PlannerUtils.requestFilter(dataNodePlan); LOGGER.debug("Sending data node plan\n{}\n with filter [{}]", dataNodePlan, requestFilter);