SpanExpression.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
package org.opensearch.sql.expression.span;
7
8
import lombok.EqualsAndHashCode;
9
import lombok.Getter;
10
import lombok.RequiredArgsConstructor;
11
import lombok.ToString;
12
import org.opensearch.sql.ast.expression.SpanUnit;
13
import org.opensearch.sql.data.model.ExprValue;
14
import org.opensearch.sql.data.type.ExprType;
15
import org.opensearch.sql.expression.Expression;
16
import org.opensearch.sql.expression.ExpressionNodeVisitor;
17
import org.opensearch.sql.expression.env.Environment;
18
19
@RequiredArgsConstructor
20
@Getter
21
@ToString
22
@EqualsAndHashCode
23
public class SpanExpression implements Expression {
24
  private final Expression field;
25
  private final Expression value;
26
  private final SpanUnit unit;
27
28
  @Override
29
  public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) {
30 1 1. valueOf : replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::valueOf → KILLED
    return value.valueOf(valueEnv);
31
  }
32
33
  /**
34
   * Return type follows the following table.
35
   *  FIELD         VALUE     RETURN_TYPE
36
   *  int/long      integer   int/long (field type)
37
   *  int/long      double    double
38
   *  float/double  integer   float/double (field type)
39
   *  float/double  double    float/double (field type)
40
   *  other         any       field type
41
   */
42
  @Override
43
  public ExprType type() {
44 1 1. type : negated conditional → KILLED
    if (field.type().isCompatible(value.type())) {
45 1 1. type : replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::type → KILLED
      return field.type();
46 1 1. type : negated conditional → KILLED
    } else if (value.type().isCompatible(field.type())) {
47 1 1. type : replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::type → KILLED
      return value.type();
48
    } else {
49 1 1. type : replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::type → KILLED
      return field.type();
50
    }
51
  }
52
53
  @Override
54
  public <T, C> T accept(ExpressionNodeVisitor<T, C> visitor, C context) {
55 1 1. accept : replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::accept → SURVIVED
    return visitor.visitNode(this, context);
56
  }
57
}

Mutations

30

1.1
Location : valueOf
Killed by : org.opensearch.sql.expression.span.SpanExpressionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.span.SpanExpressionTest]/[method:span()]
replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::valueOf → KILLED

44

1.1
Location : type
Killed by : org.opensearch.sql.expression.span.SpanExpressionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.span.SpanExpressionTest]/[method:span()]
negated conditional → KILLED

45

1.1
Location : type
Killed by : org.opensearch.sql.expression.span.SpanExpressionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.span.SpanExpressionTest]/[method:span()]
replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::type → KILLED

46

1.1
Location : type
Killed by : org.opensearch.sql.expression.span.SpanExpressionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.span.SpanExpressionTest]/[method:span()]
negated conditional → KILLED

47

1.1
Location : type
Killed by : org.opensearch.sql.expression.span.SpanExpressionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.span.SpanExpressionTest]/[method:span()]
replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::type → KILLED

49

1.1
Location : type
Killed by : org.opensearch.sql.expression.span.SpanExpressionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.span.SpanExpressionTest]/[method:span()]
replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::type → KILLED

55

1.1
Location : accept
Killed by : none
replaced return value with null for org/opensearch/sql/expression/span/SpanExpression::accept → SURVIVED

Active mutators

Tests examined


Report generated by PIT 1.9.0