77
88package org .elasticsearch .xpack .esql .enrich ;
99
10- import org .apache .logging .log4j .LogManager ;
11- import org .apache .logging .log4j .Logger ;
1210import org .apache .lucene .search .BooleanClause ;
1311import org .apache .lucene .search .BooleanQuery ;
1412import org .apache .lucene .search .Query ;
1513import org .elasticsearch .cluster .service .ClusterService ;
1614import org .elasticsearch .compute .operator .lookup .LookupEnrichQueryGenerator ;
1715import org .elasticsearch .compute .operator .lookup .QueryList ;
16+ import org .elasticsearch .index .query .QueryBuilder ;
1817import org .elasticsearch .index .query .SearchExecutionContext ;
1918import org .elasticsearch .xpack .esql .capabilities .TranslationAware ;
2019import org .elasticsearch .xpack .esql .core .expression .Expression ;
2726import org .elasticsearch .xpack .esql .stats .SearchContextStats ;
2827
2928import java .io .IOException ;
29+ import java .io .UncheckedIOException ;
3030import java .util .ArrayList ;
3131import java .util .List ;
3232
3939 * If the pre-join filter cannot be pushed down to Lucene, it will be ignored.
4040 */
4141public class ExpressionQueryList implements LookupEnrichQueryGenerator {
42- private static final Logger logger = LogManager .getLogger (ExpressionQueryList .class );
4342 private final List <QueryList > queryLists ;
4443 private final List <Query > preJoinFilters = new ArrayList <>();
4544 private final SearchExecutionContext context ;
@@ -58,14 +57,13 @@ public ExpressionQueryList(
5857 buildPreJoinFilter (rightPreJoinPlan , clusterService );
5958 }
6059
61- private void addToPreJoinFilters (org . elasticsearch . index . query . QueryBuilder query ) {
60+ private void addToPreJoinFilters (QueryBuilder query ) {
6261 try {
6362 if (query != null ) {
6463 preJoinFilters .add (query .toQuery (context ));
6564 }
6665 } catch (IOException e ) {
67- // as we treat the filter as optional an error in its application will be ignored
68- logger .error (() -> "Failed to translate optional pre-join filter: [" + query + "]" , e );
66+ throw new UncheckedIOException ("Error while building query for PreJoinFilters filter" , e );
6967 }
7068 }
7169
@@ -87,10 +85,10 @@ private void buildPreJoinFilter(PhysicalPlan rightPreJoinPlan, ClusterService cl
8785 // We can revisit this in the future if needed, once we have more optimized workflow in place.
8886 // The filter is optional, so it is OK to ignore it if it cannot be translated.
8987 }
90- } else if (rightPreJoinPlan instanceof EsSourceExec == false ) {
88+ } else if (rightPreJoinPlan != null && rightPreJoinPlan instanceof EsSourceExec == false ) {
9189 throw new IllegalStateException (
9290 "The right side of a LookupJoinExec can only be a FilterExec on top of an EsSourceExec or an EsSourceExec, but got: "
93- + rightPreJoinPlan . toString ()
91+ + rightPreJoinPlan
9492 );
9593 }
9694 }
0 commit comments