1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.expression.window.ranking; | |
8 | ||
9 | import org.opensearch.sql.expression.function.BuiltinFunctionName; | |
10 | import org.opensearch.sql.expression.window.frame.CurrentRowWindowFrame; | |
11 | ||
12 | /** | |
13 | * Row number window function that assigns row number starting from 1 to each row in a partition. | |
14 | */ | |
15 | public class RowNumberFunction extends RankingWindowFunction { | |
16 | ||
17 | public RowNumberFunction() { | |
18 | super(BuiltinFunctionName.ROW_NUMBER.getName()); | |
19 | } | |
20 | ||
21 | @Override | |
22 | protected int rank(CurrentRowWindowFrame frame) { | |
23 |
1
1. rank : negated conditional → KILLED |
if (frame.isNewPartition()) { |
24 | rank = 1; | |
25 | } | |
26 |
2
1. rank : Replaced integer addition with subtraction → KILLED 2. rank : replaced int return with 0 for org/opensearch/sql/expression/window/ranking/RowNumberFunction::rank → KILLED |
return rank++; |
27 | } | |
28 | ||
29 | } | |
Mutations | ||
23 |
1.1 |
|
26 |
1.1 2.2 |