|
34 | 34 | import java.util.function.Function;
|
35 | 35 | import java.util.function.Predicate;
|
36 | 36 |
|
| 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 | + */ |
37 | 48 | public final class PushDownAndCombineFilters extends OptimizerRules.OptimizerRule<Filter> {
|
38 | 49 | @Override
|
39 | 50 | protected LogicalPlan rule(Filter filter) {
|
@@ -73,7 +84,7 @@ protected LogicalPlan rule(Filter filter) {
|
73 | 84 | var attributes = AttributeSet.of(Expressions.asAttributes(re.extractedFields()));
|
74 | 85 | plan = maybePushDownPastUnary(filter, re, attributes::contains, NO_OP);
|
75 | 86 | } 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 |
77 | 88 | var attributes = AttributeSet.of(inferencePlan.generatedAttributes());
|
78 | 89 | plan = maybePushDownPastUnary(filter, inferencePlan, attributes::contains, NO_OP);
|
79 | 90 | } else if (child instanceof Enrich enrich) {
|
|
0 commit comments