NamedAggregator.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
7
package org.opensearch.sql.expression.aggregation;
8
9
import lombok.EqualsAndHashCode;
10
import lombok.Getter;
11
import org.opensearch.sql.data.model.ExprValue;
12
import org.opensearch.sql.expression.ExpressionNodeVisitor;
13
14
/**
15
 * NamedAggregator expression that represents expression with name.
16
 * Please see more details in associated unresolved expression operator
17
 * {@link org.opensearch.sql.ast.expression.Alias}.
18
 */
19
@EqualsAndHashCode(callSuper = false)
20
public class NamedAggregator extends Aggregator<AggregationState> {
21
22
  /**
23
   * Aggregator name.
24
   */
25
  private final String name;
26
27
  /**
28
   * Aggregator that being named.
29
   */
30
  @Getter
31
  private final Aggregator<AggregationState> delegated;
32
33
  /**
34
   * NamedAggregator.
35
   * The aggregator properties {@link #condition} and {@link #distinct}
36
   * are inherited by named aggregator to avoid errors introduced by the property inconsistency.
37
   *
38
   * @param name name
39
   * @param delegated delegated
40
   */
41
  public NamedAggregator(
42
      String name,
43
      Aggregator<AggregationState> delegated) {
44
    super(delegated.getFunctionName(), delegated.getArguments(), delegated.returnType);
45
    this.name = name;
46
    this.delegated = delegated;
47
    this.condition = delegated.condition;
48
    this.distinct = delegated.distinct;
49
  }
50
51
  @Override
52
  public AggregationState create() {
53 1 1. create : replaced return value with null for org/opensearch/sql/expression/aggregation/NamedAggregator::create → KILLED
    return delegated.create();
54
  }
55
56
  @Override
57
  protected AggregationState iterate(ExprValue value, AggregationState state) {
58 1 1. iterate : replaced return value with null for org/opensearch/sql/expression/aggregation/NamedAggregator::iterate → SURVIVED
    return delegated.iterate(value, state);
59
  }
60
61
  /**
62
   * Get expression name using name or its alias (if it's present).
63
   * @return  expression name
64
   */
65
  public String getName() {
66 1 1. getName : replaced return value with "" for org/opensearch/sql/expression/aggregation/NamedAggregator::getName → KILLED
    return name;
67
  }
68
69
  @Override
70
  public <T, C> T accept(ExpressionNodeVisitor<T, C> visitor, C context) {
71 1 1. accept : replaced return value with null for org/opensearch/sql/expression/aggregation/NamedAggregator::accept → SURVIVED
    return visitor.visitNamedAggregator(this, context);
72
  }
73
74
  @Override
75
  public String toString() {
76 1 1. toString : replaced return value with "" for org/opensearch/sql/expression/aggregation/NamedAggregator::toString → KILLED
    return getName();
77
  }
78
79
}

Mutations

53

1.1
Location : create
Killed by : org.opensearch.sql.planner.physical.AggregationOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.AggregationOperatorTest]/[method:sum_without_groups()]
replaced return value with null for org/opensearch/sql/expression/aggregation/NamedAggregator::create → KILLED

58

1.1
Location : iterate
Killed by : none
replaced return value with null for org/opensearch/sql/expression/aggregation/NamedAggregator::iterate → SURVIVED

66

1.1
Location : getName
Killed by : org.opensearch.sql.planner.physical.AggregationOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.planner.physical.AggregationOperatorTest]/[method:sum_without_groups()]
replaced return value with "" for org/opensearch/sql/expression/aggregation/NamedAggregator::getName → KILLED

71

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

76

1.1
Location : toString
Killed by : org.opensearch.sql.executor.ExplainTest.[engine:junit-jupiter]/[class:org.opensearch.sql.executor.ExplainTest]/[method:can_explain_aggregations()]
replaced return value with "" for org/opensearch/sql/expression/aggregation/NamedAggregator::toString → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0