PushFilterUnderSort.java

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.planner.logical.LogicalFilter;
18
import org.opensearch.sql.planner.logical.LogicalPlan;
19
import org.opensearch.sql.planner.logical.LogicalSort;
20
import org.opensearch.sql.planner.optimizer.Rule;
21
22
/**
23
 * Push Filter under Sort.
24
 * Filter - Sort - Child --> Sort - Filter - Child
25
 */
26
public class PushFilterUnderSort implements Rule<LogicalFilter> {
27
28
  private final Capture<LogicalSort> capture;
29
30
  @Accessors(fluent = true)
31
  @Getter
32
  private final Pattern<LogicalFilter> pattern;
33
34
  /**
35
   * Constructor of PushFilterUnderSort.
36
   */
37
  public PushFilterUnderSort() {
38
    this.capture = Capture.newCapture();
39
    this.pattern = typeOf(LogicalFilter.class)
40
        .with(source().matching(typeOf(LogicalSort.class).capturedAs(capture)));
41
  }
42
43
  @Override
44
  public LogicalPlan apply(LogicalFilter filter,
45
                           Captures captures) {
46
    LogicalSort sort = captures.get(capture);
47 1 1. apply : replaced return value with null for org/opensearch/sql/planner/optimizer/rule/PushFilterUnderSort::apply → KILLED
    return new LogicalSort(
48
        filter.replaceChildPlans(sort.getChild()),
49
        sort.getSortList()
50
    );
51
  }
52
}

Mutations

47

1.1
Location : apply
Killed by : org.opensearch.sql.planner.optimizer.LogicalPlanOptimizerTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.optimizer.LogicalPlanOptimizerTest]/[method:push_filter_under_sort()]
replaced return value with null for org/opensearch/sql/planner/optimizer/rule/PushFilterUnderSort::apply → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0