Skip to content

Commit 613e7d7

Browse files
committed
Fix missing FoldContexts
1 parent 2cf4826 commit 613e7d7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public static PhysicalPlan localPlan(
183183
/**
184184
* Extracts a filter that can be used to skip unmatched shards on the coordinator.
185185
*/
186-
public static QueryBuilder canMatchFilter(PhysicalPlan plan) {
186+
public static QueryBuilder canMatchFilter(PhysicalPlan plan, FoldContext foldContext) {
187187
return detectFilter(plan, CoordinatorRewriteContext.SUPPORTED_FIELDS::contains, foldContext);
188188
}
189189

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/QueryBuilderResolver.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.index.query.Rewriteable;
1717
import org.elasticsearch.search.SearchService;
1818
import org.elasticsearch.transport.TransportService;
19+
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
1920
import org.elasticsearch.xpack.esql.core.util.Holder;
2021
import org.elasticsearch.xpack.esql.expression.function.fulltext.FullTextFunction;
2122
import org.elasticsearch.xpack.esql.plan.logical.EsRelation;
@@ -33,7 +34,7 @@
3334
/**
3435
* Some {@link FullTextFunction} implementations such as {@link org.elasticsearch.xpack.esql.expression.function.fulltext.Match}
3536
* will be translated to a {@link QueryBuilder} that require a rewrite phase on the coordinator.
36-
* {@link QueryBuilderResolver#resolveQueryBuilders(LogicalPlan, ActionListener, BiConsumer)} will rewrite the plan by replacing
37+
* {@link QueryBuilderResolver#resolveQueryBuilders(LogicalPlan, FoldContext, ActionListener, BiConsumer)} will rewrite the plan by replacing
3738
* {@link FullTextFunction} expression with new ones that hold rewritten {@link QueryBuilder}s.
3839
*/
3940
public class QueryBuilderResolver {
@@ -56,6 +57,7 @@ public QueryBuilderResolver(
5657

5758
public void resolveQueryBuilders(
5859
LogicalPlan plan,
60+
FoldContext foldContext,
5961
ActionListener<Result> listener,
6062
BiConsumer<LogicalPlan, ActionListener<Result>> callback
6163
) {
@@ -72,7 +74,7 @@ public void resolveQueryBuilders(
7274
return;
7375
}
7476
QueryRewriteContext ctx = queryRewriteContext(indexNames);
75-
FullTextFunctionsRewritable rewritable = new FullTextFunctionsRewritable(unresolved);
77+
FullTextFunctionsRewritable rewritable = new FullTextFunctionsRewritable(unresolved, foldContext);
7678
Rewriteable.rewriteAndFetch(rewritable, ctx, new ActionListener<FullTextFunctionsRewritable>() {
7779
@Override
7880
public void onResponse(FullTextFunctionsRewritable fullTextFunctionsRewritable) {
@@ -136,11 +138,11 @@ private class FullTextFunctionsRewritable implements Rewriteable<FullTextFunctio
136138
this.queryBuilderMap = queryBuilderMap;
137139
}
138140

139-
FullTextFunctionsRewritable(Set<FullTextFunction> functions) {
141+
FullTextFunctionsRewritable(Set<FullTextFunction> functions, FoldContext foldContext) {
140142
this.queryBuilderMap = new HashMap<>();
141143

142144
for (FullTextFunction func : functions) {
143-
queryBuilderMap.put(func, TRANSLATOR_HANDLER.asQuery(func).asBuilder());
145+
queryBuilderMap.put(func, TRANSLATOR_HANDLER.asQuery(func, foldContext).asBuilder());
144146
}
145147
}
146148

0 commit comments

Comments
 (0)