@@ -180,19 +180,31 @@ public void execute(EsqlQueryRequest request, EsqlExecutionInfo executionInfo, P
180
180
analyzedPlan (parsed , executionInfo , request .filter (), new EsqlCCSUtils .CssPartialErrorsActionListener (executionInfo , listener ) {
181
181
@ Override
182
182
public void onResponse (LogicalPlan analyzedPlan ) {
183
- SubscribableListener .<LogicalPlan >newForked (l -> preOptimizedPlan (analyzedPlan , l ))
184
- .<LogicalPlan >andThen ((l , p ) -> preMapper .preMapper (optimizedPlan (p ), l ))
185
- .<Result >andThen ((l , p ) -> executeOptimizedPlan (request , executionInfo , planRunner , p , l ))
186
- .addListener (listener );
183
+ optimizeAndExecute (request , executionInfo , planRunner , analyzedPlan , listener );
187
184
}
188
185
});
189
186
}
190
187
188
+ // visible for testing in CsvTests
189
+ public void optimizeAndExecute (
190
+ EsqlQueryRequest request ,
191
+ EsqlExecutionInfo executionInfo ,
192
+ PlanRunner planRunner ,
193
+ LogicalPlan analyzedPlan ,
194
+ ActionListener <Result > listener
195
+ ) {
196
+ SubscribableListener .<LogicalPlan >newForked (l -> logicalPlanPreOptimizer .preOptimize (analyzedPlan , l ))
197
+ .andThenApply (this ::optimizedPlan )
198
+ .<LogicalPlan >andThen ((l , p ) -> preMapper .preMapper (p , l ))
199
+ .<Result >andThen ((l , p ) -> executeOptimizedPlan (request , executionInfo , planRunner , p , l ))
200
+ .addListener (listener );
201
+ }
202
+
191
203
/**
192
204
* Execute an analyzed plan. Most code should prefer calling {@link #execute} but
193
205
* this is public for testing.
194
206
*/
195
- public void executeOptimizedPlan (
207
+ private void executeOptimizedPlan (
196
208
EsqlQueryRequest request ,
197
209
EsqlExecutionInfo executionInfo ,
198
210
PlanRunner planRunner ,
@@ -792,7 +804,7 @@ private PhysicalPlan logicalPlanToPhysicalPlan(LogicalPlan optimizedPlan, EsqlQu
792
804
return EstimatesRowSize .estimateRowSize (0 , physicalPlan );
793
805
}
794
806
795
- public LogicalPlan optimizedPlan (LogicalPlan logicalPlan ) {
807
+ private LogicalPlan optimizedPlan (LogicalPlan logicalPlan ) {
796
808
if (logicalPlan .preOptimized () == false ) {
797
809
throw new IllegalStateException ("Expected pre-optimized plan" );
798
810
}
@@ -801,11 +813,7 @@ public LogicalPlan optimizedPlan(LogicalPlan logicalPlan) {
801
813
return plan ;
802
814
}
803
815
804
- public void preOptimizedPlan (LogicalPlan logicalPlan , ActionListener <LogicalPlan > listener ) {
805
- logicalPlanPreOptimizer .preOptimize (logicalPlan , listener );
806
- }
807
-
808
- public PhysicalPlan physicalPlan (LogicalPlan optimizedPlan ) {
816
+ private PhysicalPlan physicalPlan (LogicalPlan optimizedPlan ) {
809
817
if (optimizedPlan .optimized () == false ) {
810
818
throw new IllegalStateException ("Expected optimized plan" );
811
819
}
@@ -815,7 +823,7 @@ public PhysicalPlan physicalPlan(LogicalPlan optimizedPlan) {
815
823
return plan ;
816
824
}
817
825
818
- public PhysicalPlan optimizedPhysicalPlan (LogicalPlan optimizedPlan ) {
826
+ private PhysicalPlan optimizedPhysicalPlan (LogicalPlan optimizedPlan ) {
819
827
var plan = physicalPlanOptimizer .optimize (physicalPlan (optimizedPlan ));
820
828
LOGGER .debug ("Optimized physical plan:\n {}" , plan );
821
829
return plan ;
0 commit comments