Skip to content

Commit dfce035

Browse files
committed
Allow FTFs in WHERE clauses but not in grouping clauses
1 parent 8a0f48f commit dfce035

File tree

1 file changed

+11
-15
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext

1 file changed

+11
-15
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/FullTextFunction.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.elasticsearch.xpack.esql.core.type.DataType;
3333
import org.elasticsearch.xpack.esql.core.type.DataTypeConverter;
3434
import org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper;
35-
import org.elasticsearch.xpack.esql.expression.function.aggregate.FilteredExpression;
3635
import org.elasticsearch.xpack.esql.expression.predicate.logical.BinaryLogic;
3736
import org.elasticsearch.xpack.esql.expression.predicate.logical.Not;
3837
import org.elasticsearch.xpack.esql.optimizer.rules.physical.local.LucenePushdownPredicates;
@@ -228,7 +227,7 @@ private static void checkFullTextQueryFunctions(LogicalPlan plan, Failures failu
228227
);
229228
checkFullTextFunctionsParents(condition, failures);
230229
} else if (plan instanceof Aggregate agg) {
231-
agg.forEachExpression(exp -> checkFullTextFunctionsInAggs(exp, failures));
230+
checkFullTextFunctionsInAggs(agg, failures);
232231
} else {
233232
plan.forEachExpression(FullTextFunction.class, ftf -> {
234233
failures.add(
@@ -238,19 +237,16 @@ private static void checkFullTextQueryFunctions(LogicalPlan plan, Failures failu
238237
}
239238
}
240239

241-
private static void checkFullTextFunctionsInAggs(Expression expression, Failures failures) {
242-
if (expression instanceof FilteredExpression) {
243-
return;
244-
}
245-
for (Expression child : expression.children()) {
246-
if (child instanceof FullTextFunction ftf) {
247-
failures.add(
248-
fail(ftf, "[{}] {} is only supported in WHERE and STATS ... WHERE commands", ftf.functionName(), ftf.functionType())
249-
);
250-
return;
251-
}
252-
checkFullTextFunctionsInAggs(child, failures);
253-
}
240+
private static void checkFullTextFunctionsInAggs(Aggregate agg, Failures failures) {
241+
agg.groupings().forEach(exp -> {
242+
exp.forEachDown(e -> {
243+
if (e instanceof FullTextFunction ftf) {
244+
failures.add(
245+
fail(ftf, "[{}] {} is only supported in WHERE and STATS ... WHERE commands", ftf.functionName(), ftf.functionType())
246+
);
247+
}
248+
});
249+
});
254250
}
255251

256252
/**

0 commit comments

Comments
 (0)