@@ -180,31 +180,19 @@ 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- optimizeAndExecute (request , executionInfo , planRunner , analyzedPlan , listener );
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 );
184187 }
185188 });
186189 }
187190
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-
203191 /**
204192 * Execute an analyzed plan. Most code should prefer calling {@link #execute} but
205193 * this is public for testing.
206194 */
207- private void executeOptimizedPlan (
195+ public void executeOptimizedPlan (
208196 EsqlQueryRequest request ,
209197 EsqlExecutionInfo executionInfo ,
210198 PlanRunner planRunner ,
@@ -804,7 +792,7 @@ private PhysicalPlan logicalPlanToPhysicalPlan(LogicalPlan optimizedPlan, EsqlQu
804792 return EstimatesRowSize .estimateRowSize (0 , physicalPlan );
805793 }
806794
807- private LogicalPlan optimizedPlan (LogicalPlan logicalPlan ) {
795+ public LogicalPlan optimizedPlan (LogicalPlan logicalPlan ) {
808796 if (logicalPlan .preOptimized () == false ) {
809797 throw new IllegalStateException ("Expected pre-optimized plan" );
810798 }
@@ -813,7 +801,11 @@ private LogicalPlan optimizedPlan(LogicalPlan logicalPlan) {
813801 return plan ;
814802 }
815803
816- private PhysicalPlan physicalPlan (LogicalPlan optimizedPlan ) {
804+ public void preOptimizedPlan (LogicalPlan logicalPlan , ActionListener <LogicalPlan > listener ) {
805+ logicalPlanPreOptimizer .preOptimize (logicalPlan , listener );
806+ }
807+
808+ public PhysicalPlan physicalPlan (LogicalPlan optimizedPlan ) {
817809 if (optimizedPlan .optimized () == false ) {
818810 throw new IllegalStateException ("Expected optimized plan" );
819811 }
@@ -823,7 +815,7 @@ private PhysicalPlan physicalPlan(LogicalPlan optimizedPlan) {
823815 return plan ;
824816 }
825817
826- private PhysicalPlan optimizedPhysicalPlan (LogicalPlan optimizedPlan ) {
818+ public PhysicalPlan optimizedPhysicalPlan (LogicalPlan optimizedPlan ) {
827819 var plan = physicalPlanOptimizer .optimize (physicalPlan (optimizedPlan ));
828820 LOGGER .debug ("Optimized physical plan:\n {}" , plan );
829821 return plan ;
0 commit comments