Skip to content

Commit a1c2012

Browse files
authored
ESQL: Add javadoc for PushDownAndCombineFilters (#132484)
1 parent 551ade2 commit a1c2012

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/PushDownAndCombineFilters.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434
import java.util.function.Function;
3535
import java.util.function.Predicate;
3636

37+
/**
38+
* Perform filters as early as possible in the logical plan by pushing them past certain plan nodes (like {@link Eval},
39+
* {@link RegexExtract}, {@link Enrich}, {@link Project}, {@link OrderBy} and left {@link Join}s) where possible.
40+
* Ideally, the filter ends up all the way down at the data source and can be turned into a Lucene query.
41+
* When pushing down past nodes, only conditions that do not depend on fields created by those nodes are pushed down; if the condition
42+
* consists of {@code AND}s, we split out the parts that do not depend on the previous node.
43+
* For joins, it splits the filter condition into parts that can be applied to the left or right side of the join and only pushes down
44+
* the left hand side filters to the left child.
45+
*
46+
* Also combines adjacent filters using a logical {@code AND}.
47+
*/
3748
public final class PushDownAndCombineFilters extends OptimizerRules.OptimizerRule<Filter> {
3849
@Override
3950
protected LogicalPlan rule(Filter filter) {
@@ -73,7 +84,7 @@ protected LogicalPlan rule(Filter filter) {
7384
var attributes = AttributeSet.of(Expressions.asAttributes(re.extractedFields()));
7485
plan = maybePushDownPastUnary(filter, re, attributes::contains, NO_OP);
7586
} else if (child instanceof InferencePlan<?> inferencePlan) {
76-
// Push down filters that do not rely on attributes created by Cpmpletion
87+
// Push down filters that do not rely on attributes created by Completion
7788
var attributes = AttributeSet.of(inferencePlan.generatedAttributes());
7889
plan = maybePushDownPastUnary(filter, inferencePlan, attributes::contains, NO_OP);
7990
} else if (child instanceof Enrich enrich) {

0 commit comments

Comments
 (0)