Skip to content

Commit 3116545

Browse files
Address code review comments, part 2
1 parent f7ff90e commit 3116545

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/ExpressionQueryList.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77

88
package org.elasticsearch.xpack.esql.enrich;
99

10-
import org.apache.logging.log4j.LogManager;
11-
import org.apache.logging.log4j.Logger;
1210
import org.apache.lucene.search.BooleanClause;
1311
import org.apache.lucene.search.BooleanQuery;
1412
import org.apache.lucene.search.Query;
1513
import org.elasticsearch.cluster.service.ClusterService;
1614
import org.elasticsearch.compute.operator.lookup.LookupEnrichQueryGenerator;
1715
import org.elasticsearch.compute.operator.lookup.QueryList;
16+
import org.elasticsearch.index.query.QueryBuilder;
1817
import org.elasticsearch.index.query.SearchExecutionContext;
1918
import org.elasticsearch.xpack.esql.capabilities.TranslationAware;
2019
import org.elasticsearch.xpack.esql.core.expression.Expression;
@@ -27,6 +26,7 @@
2726
import org.elasticsearch.xpack.esql.stats.SearchContextStats;
2827

2928
import java.io.IOException;
29+
import java.io.UncheckedIOException;
3030
import java.util.ArrayList;
3131
import java.util.List;
3232

@@ -39,7 +39,6 @@
3939
* If the pre-join filter cannot be pushed down to Lucene, it will be ignored.
4040
*/
4141
public 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

Comments
 (0)