Project.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
7
package org.opensearch.sql.ast.tree;
8
9
import com.google.common.collect.ImmutableList;
10
import java.util.Collections;
11
import java.util.List;
12
import lombok.EqualsAndHashCode;
13
import lombok.Getter;
14
import lombok.Setter;
15
import lombok.ToString;
16
import org.opensearch.sql.ast.AbstractNodeVisitor;
17
import org.opensearch.sql.ast.expression.Argument;
18
import org.opensearch.sql.ast.expression.UnresolvedExpression;
19
20
/**
21
 * Logical plan node of Project, the interface for building the list of searching fields.
22
 */
23
@ToString
24
@Getter
25
@EqualsAndHashCode(callSuper = false)
26
public class Project extends UnresolvedPlan {
27
  @Setter
28
  private List<UnresolvedExpression> projectList;
29
  private List<Argument> argExprList;
30
  private UnresolvedPlan child;
31
32
  public Project(List<UnresolvedExpression> projectList) {
33
    this.projectList = projectList;
34
    this.argExprList = Collections.emptyList();
35
  }
36
37
  public Project(List<UnresolvedExpression> projectList, List<Argument> argExprList) {
38
    this.projectList = projectList;
39
    this.argExprList = argExprList;
40
  }
41
42
  public boolean hasArgument() {
43 2 1. hasArgument : negated conditional → KILLED
2. hasArgument : replaced boolean return with true for org/opensearch/sql/ast/tree/Project::hasArgument → KILLED
    return !argExprList.isEmpty();
44
  }
45
46
  /**
47
   * The Project could been used to exclude fields from the source.
48
   */
49
  public boolean isExcluded() {
50 1 1. isExcluded : negated conditional → NO_COVERAGE
    if (hasArgument()) {
51
      Argument argument = argExprList.get(0);
52 2 1. isExcluded : replaced boolean return with false for org/opensearch/sql/ast/tree/Project::isExcluded → NO_COVERAGE
2. isExcluded : replaced boolean return with true for org/opensearch/sql/ast/tree/Project::isExcluded → NO_COVERAGE
      return (Boolean) argument.getValue().getValue();
53
    }
54 1 1. isExcluded : replaced boolean return with true for org/opensearch/sql/ast/tree/Project::isExcluded → NO_COVERAGE
    return false;
55
  }
56
57
  @Override
58
  public Project attach(UnresolvedPlan child) {
59
    this.child = child;
60 1 1. attach : replaced return value with null for org/opensearch/sql/ast/tree/Project::attach → KILLED
    return this;
61
  }
62
63
  @Override
64
  public List<UnresolvedPlan> getChild() {
65 1 1. getChild : replaced return value with Collections.emptyList for org/opensearch/sql/ast/tree/Project::getChild → KILLED
    return ImmutableList.of(this.child);
66
  }
67
68
  @Override
69
  public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) {
70
71 1 1. accept : replaced return value with null for org/opensearch/sql/ast/tree/Project::accept → KILLED
    return nodeVisitor.visitProject(this, context);
72
  }
73
}

Mutations

43

1.1
Location : hasArgument
Killed by : org.opensearch.sql.analysis.AnalyzerTest.[engine:junit-jupiter]/[class:org.opensearch.sql.analysis.AnalyzerTest]/[method:remove_source()]
negated conditional → KILLED

2.2
Location : hasArgument
Killed by : org.opensearch.sql.analysis.AnalyzerTest.[engine:junit-jupiter]/[class:org.opensearch.sql.analysis.AnalyzerTest]/[method:ad_fitRCF_relation_without_time_field()]
replaced boolean return with true for org/opensearch/sql/ast/tree/Project::hasArgument → KILLED

50

1.1
Location : isExcluded
Killed by : none
negated conditional → NO_COVERAGE

52

1.1
Location : isExcluded
Killed by : none
replaced boolean return with false for org/opensearch/sql/ast/tree/Project::isExcluded → NO_COVERAGE

2.2
Location : isExcluded
Killed by : none
replaced boolean return with true for org/opensearch/sql/ast/tree/Project::isExcluded → NO_COVERAGE

54

1.1
Location : isExcluded
Killed by : none
replaced boolean return with true for org/opensearch/sql/ast/tree/Project::isExcluded → NO_COVERAGE

60

1.1
Location : attach
Killed by : org.opensearch.sql.analysis.SelectAnalyzeTest.[engine:junit-jupiter]/[class:org.opensearch.sql.analysis.SelectAnalyzeTest]/[method:select_and_project_all()]
replaced return value with null for org/opensearch/sql/ast/tree/Project::attach → KILLED

65

1.1
Location : getChild
Killed by : org.opensearch.sql.analysis.SelectAnalyzeTest.[engine:junit-jupiter]/[class:org.opensearch.sql.analysis.SelectAnalyzeTest]/[method:select_and_project_all()]
replaced return value with Collections.emptyList for org/opensearch/sql/ast/tree/Project::getChild → KILLED

71

1.1
Location : accept
Killed by : org.opensearch.sql.analysis.SelectAnalyzeTest.[engine:junit-jupiter]/[class:org.opensearch.sql.analysis.SelectAnalyzeTest]/[method:select_and_project_all()]
replaced return value with null for org/opensearch/sql/ast/tree/Project::accept → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0