2929import org .elasticsearch .xpack .esql .plan .logical .join .Join ;
3030import org .elasticsearch .xpack .esql .plan .logical .join .JoinConfig ;
3131import org .elasticsearch .xpack .esql .plan .logical .join .JoinTypes ;
32- import org .elasticsearch .xpack .esql .plan .physical .AggregateExec ;
3332import org .elasticsearch .xpack .esql .plan .physical .EnrichExec ;
3433import org .elasticsearch .xpack .esql .plan .physical .ExchangeExec ;
3534import org .elasticsearch .xpack .esql .plan .physical .FragmentExec ;
@@ -201,65 +200,6 @@ private PhysicalPlan mapUnary(UnaryPlan unary) {
201200 return MapperUtils .mapUnary (unary , mappedChild );
202201 }
203202
204- private PhysicalPlan mapToFragmentExec (Join logical , PhysicalPlan child ) {
205- Holder <Boolean > hasFragment = new Holder <>(false );
206- Holder <Boolean > forceLocal = new Holder <>(false );
207-
208- var childTransformed = child .transformUp (f -> {
209- if (forceLocal .get ()) {
210- return f ;
211- }
212- // Once we reached FragmentExec, we stuff our Enrich under it
213- if (f instanceof FragmentExec ) {
214- hasFragment .set (true );
215- return new FragmentExec (logical );
216- }
217- if (f instanceof EnrichExec enrichExec ) {
218- assert enrichExec .mode () != Enrich .Mode .REMOTE : "Unexpected remote ENRICH when looking for fragment" ;
219- if (enrichExec .mode () == Enrich .Mode .ANY ) {
220- return enrichExec .child ();
221- } else {
222- forceLocal .set (true );
223- return f ;
224- }
225- }
226- if (f instanceof UnaryExec unaryExec ) {
227- if (f instanceof AggregateExec ) {
228- // We can't make a fragment here...
229- assert logical .isRemote () == false : "Unexpected Aggregate inside remote join" ;
230- forceLocal .set (true );
231- return f ;
232- }
233- // No need to include LimitExec because:
234- // 1. If it's an implied limit, we have a copy of it already on the top
235- // 2. If it's a forced limit, we can't execute this as a remote join anyway.
236- if (f instanceof ExchangeExec || f instanceof TopNExec ) {
237- return f ;
238- } else {
239- return unaryExec .child ();
240- }
241- }
242- if (f instanceof LookupJoinExec ) {
243- // We shouldn't be meeting LookupJoinExec unless we can't execute this as a remote join
244- forceLocal .set (true );
245- return f ;
246- }
247- if (f instanceof MergeExec ) {
248- forceLocal .set (true );
249- return f ;
250- }
251- return f ;
252- });
253-
254- if (forceLocal .get () == false && hasFragment .get ()) {
255- return childTransformed ;
256- }
257- return null ;
258- }
259-
260- // This is a temporary hack for debugging purposes to quick switching
261- private static final boolean FRAGMENT_EXEC_HACK_ENABLED = System .getProperty ("esql.fragment_exec.hack" , "true" ).equals ("true" );
262-
263203 private PhysicalPlan mapBinary (BinaryPlan bp ) {
264204 if (bp instanceof Join join ) {
265205 JoinConfig config = join .config ();
@@ -286,17 +226,6 @@ private PhysicalPlan mapBinary(BinaryPlan bp) {
286226 return new FragmentExec (bp );
287227 }
288228
289- // if (FRAGMENT_EXEC_HACK_ENABLED) {
290- // var leftPlan = mapToFragmentExec(join, left);
291- // if (leftPlan == null) {
292- // if (join.isRemote()) {
293- // throw new EsqlIllegalArgumentException("Remote joins are not supported in this context: [" + join + "]");
294- // }
295- // } else {
296- // return leftPlan;
297- // }
298- // }
299-
300229 PhysicalPlan right = map (bp .right ());
301230 // if the right is data we can use a hash join directly
302231 if (right instanceof LocalSourceExec localData ) {
0 commit comments