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 Aggregation, the interface for building aggregation actions in queries. | |
22 | */ | |
23 | @Getter | |
24 | @Setter | |
25 | @ToString | |
26 | @EqualsAndHashCode(callSuper = false) | |
27 | public class Aggregation extends UnresolvedPlan { | |
28 | private List<UnresolvedExpression> aggExprList; | |
29 | private List<UnresolvedExpression> sortExprList; | |
30 | private List<UnresolvedExpression> groupExprList; | |
31 | private UnresolvedExpression span; | |
32 | private List<Argument> argExprList; | |
33 | private UnresolvedPlan child; | |
34 | ||
35 | /** | |
36 | * Aggregation Constructor without span and argument. | |
37 | */ | |
38 | public Aggregation(List<UnresolvedExpression> aggExprList, | |
39 | List<UnresolvedExpression> sortExprList, | |
40 | List<UnresolvedExpression> groupExprList) { | |
41 | this(aggExprList, sortExprList, groupExprList, null, Collections.emptyList()); | |
42 | } | |
43 | ||
44 | /** | |
45 | * Aggregation Constructor. | |
46 | */ | |
47 | public Aggregation(List<UnresolvedExpression> aggExprList, | |
48 | List<UnresolvedExpression> sortExprList, | |
49 | List<UnresolvedExpression> groupExprList, | |
50 | UnresolvedExpression span, | |
51 | List<Argument> argExprList) { | |
52 | this.aggExprList = aggExprList; | |
53 | this.sortExprList = sortExprList; | |
54 | this.groupExprList = groupExprList; | |
55 | this.span = span; | |
56 | this.argExprList = argExprList; | |
57 | } | |
58 | ||
59 | public boolean hasArgument() { | |
60 |
2
1. hasArgument : negated conditional → NO_COVERAGE 2. hasArgument : replaced boolean return with true for org/opensearch/sql/ast/tree/Aggregation::hasArgument → NO_COVERAGE |
return !aggExprList.isEmpty(); |
61 | } | |
62 | ||
63 | @Override | |
64 | public Aggregation attach(UnresolvedPlan child) { | |
65 | this.child = child; | |
66 |
1
1. attach : replaced return value with null for org/opensearch/sql/ast/tree/Aggregation::attach → KILLED |
return this; |
67 | } | |
68 | ||
69 | @Override | |
70 | public List<UnresolvedPlan> getChild() { | |
71 |
1
1. getChild : replaced return value with Collections.emptyList for org/opensearch/sql/ast/tree/Aggregation::getChild → KILLED |
return ImmutableList.of(this.child); |
72 | } | |
73 | ||
74 | @Override | |
75 | public <T, C> T accept(AbstractNodeVisitor<T, C> nodeVisitor, C context) { | |
76 |
1
1. accept : replaced return value with null for org/opensearch/sql/ast/tree/Aggregation::accept → KILLED |
return nodeVisitor.visitAggregation(this, context); |
77 | } | |
78 | } | |
Mutations | ||
60 |
1.1 2.2 |
|
66 |
1.1 |
|
71 |
1.1 |
|
76 |
1.1 |