WindowFunctions.java

1
/*
2
 * Copyright OpenSearch Contributors
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
6
7
package org.opensearch.sql.expression.window;
8
9
import static java.util.Collections.emptyList;
10
11
import com.google.common.collect.ImmutableMap;
12
import java.util.function.Supplier;
13
import lombok.experimental.UtilityClass;
14
import org.opensearch.sql.expression.function.BuiltinFunctionName;
15
import org.opensearch.sql.expression.function.BuiltinFunctionRepository;
16
import org.opensearch.sql.expression.function.DefaultFunctionResolver;
17
import org.opensearch.sql.expression.function.FunctionBuilder;
18
import org.opensearch.sql.expression.function.FunctionName;
19
import org.opensearch.sql.expression.function.FunctionSignature;
20
import org.opensearch.sql.expression.window.ranking.DenseRankFunction;
21
import org.opensearch.sql.expression.window.ranking.RankFunction;
22
import org.opensearch.sql.expression.window.ranking.RankingWindowFunction;
23
import org.opensearch.sql.expression.window.ranking.RowNumberFunction;
24
25
/**
26
 * Window functions that register all window functions in function repository.
27
 */
28
@UtilityClass
29
public class WindowFunctions {
30
31
  /**
32
   * Register all window functions to function repository.
33
   *
34
   * @param repository  function repository
35
   */
36
  public void register(BuiltinFunctionRepository repository) {
37 1 1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → KILLED
    repository.register(rowNumber());
38 1 1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED
    repository.register(rank());
39 1 1. register : removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED
    repository.register(denseRank());
40
  }
41
42
  private DefaultFunctionResolver rowNumber() {
43 1 1. rowNumber : replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::rowNumber → KILLED
    return rankingFunction(BuiltinFunctionName.ROW_NUMBER.getName(), RowNumberFunction::new);
44
  }
45
46
  private DefaultFunctionResolver rank() {
47 1 1. rank : replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::rank → KILLED
    return rankingFunction(BuiltinFunctionName.RANK.getName(), RankFunction::new);
48
  }
49
50
  private DefaultFunctionResolver denseRank() {
51 1 1. denseRank : replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::denseRank → KILLED
    return rankingFunction(BuiltinFunctionName.DENSE_RANK.getName(), DenseRankFunction::new);
52
  }
53
54
  private DefaultFunctionResolver rankingFunction(FunctionName functionName,
55
                                                  Supplier<RankingWindowFunction> constructor) {
56
    FunctionSignature functionSignature = new FunctionSignature(functionName, emptyList());
57 1 1. lambda$rankingFunction$0 : replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::lambda$rankingFunction$0 → KILLED
    FunctionBuilder functionBuilder = arguments -> constructor.get();
58 1 1. rankingFunction : replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::rankingFunction → KILLED
    return new DefaultFunctionResolver(functionName,
59
        ImmutableMap.of(functionSignature, functionBuilder));
60
  }
61
62
}

Mutations

37

1.1
Location : register
Killed by : org.opensearch.sql.analysis.AnalyzerTest.[engine:junit-jupiter]/[class:org.opensearch.sql.analysis.AnalyzerTest]/[method:window_function()]
removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → KILLED

38

1.1
Location : register
Killed by : none
removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED

39

1.1
Location : register
Killed by : none
removed call to org/opensearch/sql/expression/function/BuiltinFunctionRepository::register → SURVIVED

43

1.1
Location : rowNumber
Killed by : org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest]/[method:castStringToLongException()]
replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::rowNumber → KILLED

47

1.1
Location : rank
Killed by : org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest]/[method:castStringToLongException()]
replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::rank → KILLED

51

1.1
Location : denseRank
Killed by : org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest]/[method:castStringToLongException()]
replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::denseRank → KILLED

57

1.1
Location : lambda$rankingFunction$0
Killed by : org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.window.ranking.RankingWindowFunctionTest]/[method:test_value_of()]
replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::lambda$rankingFunction$0 → KILLED

58

1.1
Location : rankingFunction
Killed by : org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest.[engine:junit-jupiter]/[class:org.opensearch.sql.expression.operator.convert.TypeCastOperatorTest]/[method:castStringToLongException()]
replaced return value with null for org/opensearch/sql/expression/window/WindowFunctions::rankingFunction → KILLED

Active mutators

Tests examined


Report generated by PIT 1.9.0