1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.planner.optimizer.rule; | |
8 | ||
9 | import static com.facebook.presto.matching.Pattern.typeOf; | |
10 | import static org.opensearch.sql.planner.optimizer.pattern.Patterns.source; | |
11 | ||
12 | import com.facebook.presto.matching.Capture; | |
13 | import com.facebook.presto.matching.Captures; | |
14 | import com.facebook.presto.matching.Pattern; | |
15 | import lombok.Getter; | |
16 | import lombok.experimental.Accessors; | |
17 | import org.opensearch.sql.expression.DSL; | |
18 | import org.opensearch.sql.planner.logical.LogicalFilter; | |
19 | import org.opensearch.sql.planner.logical.LogicalPlan; | |
20 | import org.opensearch.sql.planner.optimizer.Rule; | |
21 | ||
22 | /** | |
23 | * Merge Filter --> Filter to the single Filter condition. | |
24 | */ | |
25 | public class MergeFilterAndFilter implements Rule<LogicalFilter> { | |
26 | ||
27 | private final Capture<LogicalFilter> capture; | |
28 | ||
29 | private final DSL dsl; | |
30 | ||
31 | @Accessors(fluent = true) | |
32 | @Getter | |
33 | private final Pattern<LogicalFilter> pattern; | |
34 | ||
35 | /** | |
36 | * Constructor of MergeFilterAndFilter. | |
37 | */ | |
38 | public MergeFilterAndFilter(DSL dsl) { | |
39 | this.dsl = dsl; | |
40 | this.capture = Capture.newCapture(); | |
41 | this.pattern = typeOf(LogicalFilter.class) | |
42 | .with(source().matching(typeOf(LogicalFilter.class).capturedAs(capture))); | |
43 | } | |
44 | ||
45 | @Override | |
46 | public LogicalPlan apply(LogicalFilter filter, | |
47 | Captures captures) { | |
48 | LogicalFilter childFilter = captures.get(capture); | |
49 |
1
1. apply : replaced return value with null for org/opensearch/sql/planner/optimizer/rule/MergeFilterAndFilter::apply → KILLED |
return new LogicalFilter( |
50 | childFilter.getChild().get(0), | |
51 | dsl.and(filter.getCondition(), childFilter.getCondition()) | |
52 | ); | |
53 | } | |
54 | } | |
Mutations | ||
49 |
1.1 |