@@ -180,19 +180,31 @@ public void execute(EsqlQueryRequest request, EsqlExecutionInfo executionInfo, P
180180 analyzedPlan (parsed , executionInfo , request .filter (), new EsqlCCSUtils .CssPartialErrorsActionListener (executionInfo , listener ) {
181181 @ Override
182182 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 );
187184 }
188185 });
189186 }
190187
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+
191203 /**
192204 * Execute an analyzed plan. Most code should prefer calling {@link #execute} but
193205 * this is public for testing.
194206 */
195- public void executeOptimizedPlan (
207+ private void executeOptimizedPlan (
196208 EsqlQueryRequest request ,
197209 EsqlExecutionInfo executionInfo ,
198210 PlanRunner planRunner ,
@@ -792,7 +804,7 @@ private PhysicalPlan logicalPlanToPhysicalPlan(LogicalPlan optimizedPlan, EsqlQu
792804 return EstimatesRowSize .estimateRowSize (0 , physicalPlan );
793805 }
794806
795- public LogicalPlan optimizedPlan (LogicalPlan logicalPlan ) {
807+ private LogicalPlan optimizedPlan (LogicalPlan logicalPlan ) {
796808 if (logicalPlan .preOptimized () == false ) {
797809 throw new IllegalStateException ("Expected pre-optimized plan" );
798810 }
@@ -801,11 +813,7 @@ public LogicalPlan optimizedPlan(LogicalPlan logicalPlan) {
801813 return plan ;
802814 }
803815
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 ) {
809817 if (optimizedPlan .optimized () == false ) {
810818 throw new IllegalStateException ("Expected optimized plan" );
811819 }
@@ -815,7 +823,7 @@ public PhysicalPlan physicalPlan(LogicalPlan optimizedPlan) {
815823 return plan ;
816824 }
817825
818- public PhysicalPlan optimizedPhysicalPlan (LogicalPlan optimizedPlan ) {
826+ private PhysicalPlan optimizedPhysicalPlan (LogicalPlan optimizedPlan ) {
819827 var plan = physicalPlanOptimizer .optimize (physicalPlan (optimizedPlan ));
820828 LOGGER .debug ("Optimized physical plan:\n {}" , plan );
821829 return plan ;
0 commit comments