1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.planner.logical; | |
8 | ||
9 | import com.google.common.collect.ImmutableList; | |
10 | import com.google.common.collect.ImmutableSet; | |
11 | import java.util.Arrays; | |
12 | import java.util.List; | |
13 | import java.util.Map; | |
14 | import java.util.stream.Collectors; | |
15 | import lombok.experimental.UtilityClass; | |
16 | import org.apache.commons.lang3.tuple.Pair; | |
17 | import org.opensearch.sql.ast.expression.Literal; | |
18 | import org.opensearch.sql.ast.tree.RareTopN.CommandType; | |
19 | import org.opensearch.sql.ast.tree.Sort.SortOption; | |
20 | import org.opensearch.sql.data.model.ExprCollectionValue; | |
21 | import org.opensearch.sql.expression.Expression; | |
22 | import org.opensearch.sql.expression.LiteralExpression; | |
23 | import org.opensearch.sql.expression.NamedExpression; | |
24 | import org.opensearch.sql.expression.ReferenceExpression; | |
25 | import org.opensearch.sql.expression.aggregation.NamedAggregator; | |
26 | import org.opensearch.sql.expression.window.WindowDefinition; | |
27 | import org.opensearch.sql.storage.Table; | |
28 | ||
29 | /** | |
30 | * Logical Plan DSL. | |
31 | */ | |
32 | @UtilityClass | |
33 | public class LogicalPlanDSL { | |
34 | ||
35 | public static LogicalPlan aggregation( | |
36 | LogicalPlan input, List<NamedAggregator> aggregatorList, List<NamedExpression> groupByList) { | |
37 |
1
1. aggregation : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::aggregation → KILLED |
return new LogicalAggregation(input, aggregatorList, groupByList); |
38 | } | |
39 | ||
40 | public static LogicalPlan filter(LogicalPlan input, Expression expression) { | |
41 |
1
1. filter : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::filter → KILLED |
return new LogicalFilter(input, expression); |
42 | } | |
43 | ||
44 | public static LogicalPlan relation(String tableName, Table table) { | |
45 |
1
1. relation : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::relation → KILLED |
return new LogicalRelation(tableName, table); |
46 | } | |
47 | ||
48 | public static LogicalPlan rename( | |
49 | LogicalPlan input, Map<ReferenceExpression, ReferenceExpression> renameMap) { | |
50 |
1
1. rename : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::rename → KILLED |
return new LogicalRename(input, renameMap); |
51 | } | |
52 | ||
53 | public static LogicalPlan project(LogicalPlan input, NamedExpression... fields) { | |
54 |
1
1. project : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::project → KILLED |
return new LogicalProject(input, Arrays.asList(fields), ImmutableList.of()); |
55 | } | |
56 | ||
57 | public static LogicalPlan project(LogicalPlan input, List<NamedExpression> fields, | |
58 | List<NamedExpression> namedParseExpressions) { | |
59 |
1
1. project : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::project → KILLED |
return new LogicalProject(input, fields, namedParseExpressions); |
60 | } | |
61 | ||
62 | public LogicalPlan window(LogicalPlan input, | |
63 | NamedExpression windowFunction, | |
64 | WindowDefinition windowDefinition) { | |
65 |
1
1. window : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::window → KILLED |
return new LogicalWindow(input, windowFunction, windowDefinition); |
66 | } | |
67 | ||
68 | public LogicalPlan highlight(LogicalPlan input, Expression field, | |
69 | Map<String, Literal> arguments) { | |
70 |
1
1. highlight : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::highlight → KILLED |
return new LogicalHighlight(input, field, arguments); |
71 | } | |
72 | ||
73 | public static LogicalPlan remove(LogicalPlan input, ReferenceExpression... fields) { | |
74 |
1
1. remove : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::remove → KILLED |
return new LogicalRemove(input, ImmutableSet.copyOf(fields)); |
75 | } | |
76 | ||
77 | public static LogicalPlan eval( | |
78 | LogicalPlan input, Pair<ReferenceExpression, Expression>... expressions) { | |
79 |
1
1. eval : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::eval → KILLED |
return new LogicalEval(input, Arrays.asList(expressions)); |
80 | } | |
81 | ||
82 | public static LogicalPlan sort(LogicalPlan input, Pair<SortOption, Expression>... sorts) { | |
83 |
1
1. sort : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::sort → KILLED |
return new LogicalSort(input, Arrays.asList(sorts)); |
84 | } | |
85 | ||
86 | public static LogicalPlan dedupe(LogicalPlan input, Expression... fields) { | |
87 |
1
1. dedupe : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::dedupe → KILLED |
return dedupe(input, 1, false, false, fields); |
88 | } | |
89 | ||
90 | public static LogicalPlan dedupe( | |
91 | LogicalPlan input, | |
92 | int allowedDuplication, | |
93 | boolean keepEmpty, | |
94 | boolean consecutive, | |
95 | Expression... fields) { | |
96 |
1
1. dedupe : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::dedupe → KILLED |
return new LogicalDedupe( |
97 | input, Arrays.asList(fields), allowedDuplication, keepEmpty, consecutive); | |
98 | } | |
99 | ||
100 | public static LogicalPlan rareTopN(LogicalPlan input, CommandType commandType, | |
101 | List<Expression> groupByList, Expression... fields) { | |
102 |
1
1. rareTopN : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::rareTopN → KILLED |
return rareTopN(input, commandType, 10, groupByList, fields); |
103 | } | |
104 | ||
105 | public static LogicalPlan rareTopN(LogicalPlan input, CommandType commandType, int noOfResults, | |
106 | List<Expression> groupByList, Expression... fields) { | |
107 |
1
1. rareTopN : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::rareTopN → KILLED |
return new LogicalRareTopN(input, commandType, noOfResults, Arrays.asList(fields), groupByList); |
108 | } | |
109 | ||
110 | @SafeVarargs | |
111 | public LogicalPlan values(List<LiteralExpression>... values) { | |
112 |
1
1. values : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::values → KILLED |
return new LogicalValues(Arrays.asList(values)); |
113 | } | |
114 | ||
115 | public static LogicalPlan limit(LogicalPlan input, Integer limit, Integer offset) { | |
116 |
1
1. limit : replaced return value with null for org/opensearch/sql/planner/logical/LogicalPlanDSL::limit → KILLED |
return new LogicalLimit(input, limit, offset); |
117 | } | |
118 | ||
119 | } | |
Mutations | ||
37 |
1.1 |
|
41 |
1.1 |
|
45 |
1.1 |
|
50 |
1.1 |
|
54 |
1.1 |
|
59 |
1.1 |
|
65 |
1.1 |
|
70 |
1.1 |
|
74 |
1.1 |
|
79 |
1.1 |
|
83 |
1.1 |
|
87 |
1.1 |
|
96 |
1.1 |
|
102 |
1.1 |
|
107 |
1.1 |
|
112 |
1.1 |
|
116 |
1.1 |