From 74bbe73c84a3e579c782842fd5d1ec8743c3572c Mon Sep 17 00:00:00 2001 From: currantw Date: Mon, 9 Dec 2024 12:50:49 -0800 Subject: [PATCH] Replace `Collections.singletonList` with `List.of` Signed-off-by: currantw --- .../cluster/ClusterManagerEventListener.java | 3 +- .../BasicAuthenticationInterceptorTest.java | 6 +- .../sql/analysis/ExpressionAnalyzer.java | 3 +- .../analysis/SelectExpressionAnalyzer.java | 7 +- .../sql/ast/expression/AggregateFunction.java | 3 +- .../sql/ast/expression/Argument.java | 4 +- .../opensearch/sql/ast/expression/Cast.java | 3 +- .../org/opensearch/sql/ast/expression/In.java | 4 +- .../sql/ast/expression/Interval.java | 4 +- .../opensearch/sql/ast/expression/Not.java | 4 +- .../sql/ast/expression/QualifiedName.java | 3 +- .../ast/expression/UnresolvedArgument.java | 4 +- .../org/opensearch/sql/ast/tree/RareTopN.java | 4 +- .../org/opensearch/sql/ast/tree/Relation.java | 4 +- .../aggregation/AggregatorFunctions.java | 60 ++++----- .../sql/expression/function/FunctionDSL.java | 4 +- .../sql/expression/text/TextFunctions.java | 3 +- .../sql/planner/logical/LogicalAD.java | 5 +- .../planner/logical/LogicalAggregation.java | 4 +- .../sql/planner/logical/LogicalDedupe.java | 4 +- .../sql/planner/logical/LogicalEval.java | 4 +- .../sql/planner/logical/LogicalFilter.java | 5 +- .../sql/planner/logical/LogicalHighlight.java | 5 +- .../sql/planner/logical/LogicalLimit.java | 5 +- .../sql/planner/logical/LogicalML.java | 5 +- .../sql/planner/logical/LogicalMLCommons.java | 5 +- .../sql/planner/logical/LogicalNested.java | 4 +- .../sql/planner/logical/LogicalProject.java | 4 +- .../sql/planner/logical/LogicalRareTopN.java | 4 +- .../sql/planner/logical/LogicalRemove.java | 5 +- .../sql/planner/logical/LogicalRename.java | 5 +- .../sql/planner/logical/LogicalSort.java | 4 +- .../sql/planner/logical/LogicalWindow.java | 5 +- .../sql/planner/logical/LogicalWrite.java | 4 +- .../planner/physical/AggregationOperator.java | 4 +- .../sql/planner/physical/DedupeOperator.java | 4 +- .../sql/planner/physical/EvalOperator.java | 3 +- .../sql/planner/physical/FilterOperator.java | 4 +- .../sql/planner/physical/NestedOperator.java | 3 +- .../sql/planner/physical/ProjectOperator.java | 4 +- .../planner/physical/RareTopNOperator.java | 4 +- .../sql/planner/physical/RemoveOperator.java | 3 +- .../sql/planner/physical/RenameOperator.java | 3 +- .../sql/planner/physical/SortOperator.java | 4 +- .../planner/physical/TakeOrderedOperator.java | 4 +- .../sql/planner/physical/WindowOperator.java | 4 +- .../physical/collector/MetricCollector.java | 4 +- .../assigner/TumblingWindowAssigner.java | 4 +- .../sql/storage/write/TableWriteBuilder.java | 5 +- .../sql/storage/write/TableWriteOperator.java | 4 +- .../opensearch/sql/analysis/AnalyzerTest.java | 7 +- .../sql/analysis/AnalyzerTestBase.java | 3 +- .../SelectExpressionAnalyzerTest.java | 5 +- .../opensearch/sql/executor/ExplainTest.java | 27 ++-- .../expression/ExpressionNodeVisitorTest.java | 3 +- .../BuiltinFunctionRepositoryTest.java | 3 +- .../sql/planner/DefaultImplementorTest.java | 5 +- .../physical/AggregationOperatorTest.java | 124 ++++++++---------- .../physical/RareTopNOperatorTest.java | 15 +-- .../planner/physical/RenameOperatorTest.java | 5 +- .../assigner/TumblingWindowAssignerTest.java | 8 +- .../storage/write/TableWriteOperatorTest.java | 4 +- .../service/DataSourceServiceImplTest.java | 16 +-- ...enSearchDataSourceMetadataStorageTest.java | 11 +- .../utils/DatasourceValidationUtilsTest.java | 6 +- .../sql/legacy/PrettyFormatResponseIT.java | 11 +- .../executor/format/DeleteResultSet.java | 5 +- .../core/builder/UnaryExpressionBuilder.java | 4 +- .../legacy/antlr/SymbolSimilarityTest.java | 3 +- .../antlr/semantic/types/GenericTypeTest.java | 12 +- .../antlr/semantic/types/ProductTypeTest.java | 18 +-- .../format/BindingTupleResultSetTest.java | 3 +- .../planner/physical/ADOperator.java | 5 +- .../planner/physical/MLCommonsOperator.java | 3 +- .../planner/physical/MLOperator.java | 4 +- .../agg/NoBucketAggregationParser.java | 4 +- .../aggregation/AggregationQueryBuilder.java | 4 +- .../physical/MLCommonsOperatorTest.java | 4 +- .../planner/physical/MLOperatorTest.java | 4 +- .../request/OpenSearchRequestBuilderTest.java | 5 +- .../OpenSearchIndexScanOptimizationTest.java | 5 +- .../AggregationQueryBuilderTest.java | 5 +- .../dsl/MetricAggregationBuilderTest.java | 19 ++- .../filter/ExpressionFilterScriptTest.java | 3 +- .../system/OpenSearchSystemIndexScanTest.java | 4 +- .../sql/opensearch/utils/Utils.java | 6 +- .../org/opensearch/sql/plugin/SQLPlugin.java | 3 +- .../sql/ppl/utils/ArgumentFactory.java | 7 +- .../ppl/utils/UnresolvedPlanHelperTest.java | 4 +- .../client/PrometheusClientImplTest.java | 6 +- ...eryRangeFunctionTableScanOperatorTest.java | 12 +- .../PrometheusListMetricsRequestTest.java | 6 +- .../storage/PrometheusMetricScanTest.java | 4 +- .../storage/PrometheusStorageFactoryTest.java | 4 +- .../system/PrometheusSystemTableScanTest.java | 4 +- .../protocol/response/QueryResultTest.java | 9 +- .../sql/spark/storage/SparkStorageEngine.java | 5 +- .../opensearch/sql/sql/parser/AstBuilder.java | 8 +- .../sql/sql/parser/AstExpressionBuilder.java | 5 +- 99 files changed, 285 insertions(+), 426 deletions(-) diff --git a/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java b/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java index 69be1a3fc7..eb83afdf7b 100644 --- a/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java +++ b/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java @@ -5,7 +5,6 @@ package org.opensearch.sql.spark.cluster; -import static java.util.Collections.singletonList; import static org.opensearch.sql.spark.data.constants.SparkConstants.SPARK_REQUEST_BUFFER_INDEX_NAME; import com.google.common.annotations.VisibleForTesting; @@ -183,7 +182,7 @@ private void cancel(Cancellable cron) { @VisibleForTesting public List getFlintIndexRetentionCron() { - return singletonList(flintIndexRetentionCron); + return List.of(flintIndexRetentionCron); } private String executorName() { diff --git a/common/src/test/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptorTest.java b/common/src/test/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptorTest.java index 165f9e63f7..4e14482cc1 100644 --- a/common/src/test/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptorTest.java +++ b/common/src/test/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptorTest.java @@ -7,8 +7,7 @@ package org.opensearch.sql.common.interceptors; -import static java.util.Collections.singletonList; - +import java.util.List; import lombok.SneakyThrows; import okhttp3.Credentials; import okhttp3.Interceptor; @@ -48,7 +47,6 @@ void testIntercept() { Mockito.verify(chain).proceed(requestArgumentCaptor.capture()); Request request = requestArgumentCaptor.getValue(); Assertions.assertEquals( - singletonList(Credentials.basic("testAdmin", "testPassword")), - request.headers("Authorization")); + List.of(Credentials.basic("testAdmin", "testPassword")), request.headers("Authorization")); } } diff --git a/core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java b/core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java index 370dd881c7..bef62fa408 100644 --- a/core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java +++ b/core/src/main/java/org/opensearch/sql/analysis/ExpressionAnalyzer.java @@ -5,7 +5,6 @@ package org.opensearch.sql.analysis; -import static java.util.Collections.singletonList; import static org.opensearch.sql.ast.dsl.AstDSL.and; import static org.opensearch.sql.ast.dsl.AstDSL.compare; @@ -83,7 +82,7 @@ public Expression visitCast(Cast node, AnalysisContext context) { final Expression expression = node.getExpression().accept(this, context); return (Expression) repository.compile( - context.getFunctionProperties(), node.convertFunctionName(), singletonList(expression)); + context.getFunctionProperties(), node.convertFunctionName(), List.of(expression)); } public ExpressionAnalyzer(BuiltinFunctionRepository repository) { diff --git a/core/src/main/java/org/opensearch/sql/analysis/SelectExpressionAnalyzer.java b/core/src/main/java/org/opensearch/sql/analysis/SelectExpressionAnalyzer.java index 2abbb6d96f..d296ad6573 100644 --- a/core/src/main/java/org/opensearch/sql/analysis/SelectExpressionAnalyzer.java +++ b/core/src/main/java/org/opensearch/sql/analysis/SelectExpressionAnalyzer.java @@ -5,8 +5,6 @@ package org.opensearch.sql.analysis; -import static java.util.Collections.singletonList; - import com.google.common.collect.ImmutableList; import java.util.List; import java.util.Map; @@ -55,7 +53,7 @@ public List analyze( @Override public List visitField(Field node, AnalysisContext context) { - return singletonList(DSL.named(node.accept(expressionAnalyzer, context))); + return List.of(DSL.named(node.accept(expressionAnalyzer, context))); } @Override @@ -66,8 +64,7 @@ public List visitAlias(Alias node, AnalysisContext context) { } Expression expr = referenceIfSymbolDefined(node, context); - return singletonList( - DSL.named(unqualifiedNameIfFieldOnly(node, context), expr, node.getAlias())); + return List.of(DSL.named(unqualifiedNameIfFieldOnly(node, context), expr, node.getAlias())); } /** diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/AggregateFunction.java b/core/src/main/java/org/opensearch/sql/ast/expression/AggregateFunction.java index 5335e3dfa2..26d0c39c61 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/AggregateFunction.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/AggregateFunction.java @@ -6,7 +6,6 @@ package org.opensearch.sql.ast.expression; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import java.util.List; import lombok.EqualsAndHashCode; @@ -63,7 +62,7 @@ public AggregateFunction(String funcName, UnresolvedExpression field, Boolean di @Override public List getChild() { - return singletonList(field); + return List.of(field); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/Argument.java b/core/src/main/java/org/opensearch/sql/ast/expression/Argument.java index f187dcd1d9..b4e860811f 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/Argument.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/Argument.java @@ -5,8 +5,6 @@ package org.opensearch.sql.ast.expression; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +24,7 @@ public class Argument extends UnresolvedExpression { // private final DataType valueType; @Override public List getChild() { - return singletonList(value); + return List.of(value); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/Cast.java b/core/src/main/java/org/opensearch/sql/ast/expression/Cast.java index b922198028..77719b000b 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/Cast.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/Cast.java @@ -5,7 +5,6 @@ package org.opensearch.sql.ast.expression; -import static java.util.Collections.singletonList; import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_BOOLEAN; import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_BYTE; import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_DATE; @@ -99,7 +98,7 @@ public FunctionName convertFunctionName() { @Override public List getChild() { - return singletonList(expression); + return List.of(expression); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/In.java b/core/src/main/java/org/opensearch/sql/ast/expression/In.java index 78c958a93e..00f4150242 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/In.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/In.java @@ -5,8 +5,6 @@ package org.opensearch.sql.ast.expression; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -29,7 +27,7 @@ public class In extends UnresolvedExpression { @Override public List getChild() { - return singletonList(field); + return List.of(field); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/Interval.java b/core/src/main/java/org/opensearch/sql/ast/expression/Interval.java index 82ff1b93cf..6ffc86497d 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/Interval.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/Interval.java @@ -5,8 +5,6 @@ package org.opensearch.sql.ast.expression; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +28,7 @@ public Interval(UnresolvedExpression value, String unit) { @Override public List getChild() { - return singletonList(value); + return List.of(value); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/Not.java b/core/src/main/java/org/opensearch/sql/ast/expression/Not.java index 1dcb59c4b8..1794c75080 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/Not.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/Not.java @@ -5,8 +5,6 @@ package org.opensearch.sql.ast.expression; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +22,7 @@ public class Not extends UnresolvedExpression { @Override public List getChild() { - return singletonList(expression); + return List.of(expression); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/QualifiedName.java b/core/src/main/java/org/opensearch/sql/ast/expression/QualifiedName.java index 09789d8ca2..c105dfb762 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/QualifiedName.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/QualifiedName.java @@ -5,7 +5,6 @@ package org.opensearch.sql.ast.expression; -import static java.util.Collections.singletonList; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toList; @@ -25,7 +24,7 @@ public class QualifiedName extends UnresolvedExpression { private final List parts; public QualifiedName(String name) { - this.parts = singletonList(name); + this.parts = List.of(name); } /** QualifiedName Constructor. */ diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/UnresolvedArgument.java b/core/src/main/java/org/opensearch/sql/ast/expression/UnresolvedArgument.java index 18fd13a4e7..cd826e8d90 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/UnresolvedArgument.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/UnresolvedArgument.java @@ -5,8 +5,6 @@ package org.opensearch.sql.ast.expression; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +26,7 @@ public UnresolvedArgument(String argName, UnresolvedExpression value) { @Override public List getChild() { - return singletonList(value); + return List.of(value); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java b/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java index 05f3a178a9..6c0d203a00 100644 --- a/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java +++ b/core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java @@ -5,8 +5,6 @@ package org.opensearch.sql.ast.tree; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; @@ -42,7 +40,7 @@ public RareTopN attach(UnresolvedPlan child) { @Override public List getChild() { - return singletonList(this.child); + return List.of(this.child); } @Override diff --git a/core/src/main/java/org/opensearch/sql/ast/tree/Relation.java b/core/src/main/java/org/opensearch/sql/ast/tree/Relation.java index 09faca70fb..0256ae4124 100644 --- a/core/src/main/java/org/opensearch/sql/ast/tree/Relation.java +++ b/core/src/main/java/org/opensearch/sql/ast/tree/Relation.java @@ -5,8 +5,6 @@ package org.opensearch.sql.ast.tree; -import static java.util.Collections.singletonList; - import com.google.common.collect.ImmutableList; import java.util.List; import java.util.stream.Collectors; @@ -33,7 +31,7 @@ public Relation(UnresolvedExpression tableName) { } public Relation(UnresolvedExpression tableName, String alias) { - this.tableName = singletonList(tableName); + this.tableName = List.of(tableName); this.alias = alias; } diff --git a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java index c54c1bcc9c..9a0a297cd6 100644 --- a/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java +++ b/core/src/main/java/org/opensearch/sql/expression/aggregation/AggregatorFunctions.java @@ -5,7 +5,6 @@ package org.opensearch.sql.expression.aggregation; -import static java.util.Collections.singletonList; import static org.opensearch.sql.data.type.ExprCoreType.ARRAY; import static org.opensearch.sql.data.type.ExprCoreType.DATE; import static org.opensearch.sql.data.type.ExprCoreType.DOUBLE; @@ -22,6 +21,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import java.util.List; import java.util.stream.Collectors; import lombok.experimental.UtilityClass; import org.opensearch.sql.data.type.ExprCoreType; @@ -66,16 +66,16 @@ private static DefaultFunctionResolver avg() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> new AvgAggregator(arguments, DOUBLE)) .put( - new FunctionSignature(functionName, singletonList(DATE)), + new FunctionSignature(functionName, List.of(DATE)), (functionProperties, arguments) -> new AvgAggregator(arguments, DATE)) .put( - new FunctionSignature(functionName, singletonList(TIME)), + new FunctionSignature(functionName, List.of(TIME)), (functionProperties, arguments) -> new AvgAggregator(arguments, TIME)) .put( - new FunctionSignature(functionName, singletonList(TIMESTAMP)), + new FunctionSignature(functionName, List.of(TIMESTAMP)), (functionProperties, arguments) -> new AvgAggregator(arguments, TIMESTAMP)) .build()); } @@ -88,7 +88,7 @@ private static DefaultFunctionResolver count() { ExprCoreType.coreTypes().stream() .collect( Collectors.toMap( - type -> new FunctionSignature(functionName, singletonList(type)), + type -> new FunctionSignature(functionName, List.of(type)), type -> (functionProperties, arguments) -> new CountAggregator(arguments, INTEGER)))); @@ -101,16 +101,16 @@ private static DefaultFunctionResolver sum() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(INTEGER)), + new FunctionSignature(functionName, List.of(INTEGER)), (functionProperties, arguments) -> new SumAggregator(arguments, INTEGER)) .put( - new FunctionSignature(functionName, singletonList(LONG)), + new FunctionSignature(functionName, List.of(LONG)), (functionProperties, arguments) -> new SumAggregator(arguments, LONG)) .put( - new FunctionSignature(functionName, singletonList(FLOAT)), + new FunctionSignature(functionName, List.of(FLOAT)), (functionProperties, arguments) -> new SumAggregator(arguments, FLOAT)) .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> new SumAggregator(arguments, DOUBLE)) .build()); } @@ -121,28 +121,28 @@ private static DefaultFunctionResolver min() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(INTEGER)), + new FunctionSignature(functionName, List.of(INTEGER)), (functionProperties, arguments) -> new MinAggregator(arguments, INTEGER)) .put( - new FunctionSignature(functionName, singletonList(LONG)), + new FunctionSignature(functionName, List.of(LONG)), (functionProperties, arguments) -> new MinAggregator(arguments, LONG)) .put( - new FunctionSignature(functionName, singletonList(FLOAT)), + new FunctionSignature(functionName, List.of(FLOAT)), (functionProperties, arguments) -> new MinAggregator(arguments, FLOAT)) .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> new MinAggregator(arguments, DOUBLE)) .put( - new FunctionSignature(functionName, singletonList(STRING)), + new FunctionSignature(functionName, List.of(STRING)), (functionProperties, arguments) -> new MinAggregator(arguments, STRING)) .put( - new FunctionSignature(functionName, singletonList(DATE)), + new FunctionSignature(functionName, List.of(DATE)), (functionProperties, arguments) -> new MinAggregator(arguments, DATE)) .put( - new FunctionSignature(functionName, singletonList(TIME)), + new FunctionSignature(functionName, List.of(TIME)), (functionProperties, arguments) -> new MinAggregator(arguments, TIME)) .put( - new FunctionSignature(functionName, singletonList(TIMESTAMP)), + new FunctionSignature(functionName, List.of(TIMESTAMP)), (functionProperties, arguments) -> new MinAggregator(arguments, TIMESTAMP)) .build()); } @@ -153,28 +153,28 @@ private static DefaultFunctionResolver max() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(INTEGER)), + new FunctionSignature(functionName, List.of(INTEGER)), (functionProperties, arguments) -> new MaxAggregator(arguments, INTEGER)) .put( - new FunctionSignature(functionName, singletonList(LONG)), + new FunctionSignature(functionName, List.of(LONG)), (functionProperties, arguments) -> new MaxAggregator(arguments, LONG)) .put( - new FunctionSignature(functionName, singletonList(FLOAT)), + new FunctionSignature(functionName, List.of(FLOAT)), (functionProperties, arguments) -> new MaxAggregator(arguments, FLOAT)) .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> new MaxAggregator(arguments, DOUBLE)) .put( - new FunctionSignature(functionName, singletonList(STRING)), + new FunctionSignature(functionName, List.of(STRING)), (functionProperties, arguments) -> new MaxAggregator(arguments, STRING)) .put( - new FunctionSignature(functionName, singletonList(DATE)), + new FunctionSignature(functionName, List.of(DATE)), (functionProperties, arguments) -> new MaxAggregator(arguments, DATE)) .put( - new FunctionSignature(functionName, singletonList(TIME)), + new FunctionSignature(functionName, List.of(TIME)), (functionProperties, arguments) -> new MaxAggregator(arguments, TIME)) .put( - new FunctionSignature(functionName, singletonList(TIMESTAMP)), + new FunctionSignature(functionName, List.of(TIMESTAMP)), (functionProperties, arguments) -> new MaxAggregator(arguments, TIMESTAMP)) .build()); } @@ -185,7 +185,7 @@ private static DefaultFunctionResolver varSamp() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> varianceSample(arguments, DOUBLE)) .build()); } @@ -196,7 +196,7 @@ private static DefaultFunctionResolver varPop() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> variancePopulation(arguments, DOUBLE)) .build()); } @@ -207,7 +207,7 @@ private static DefaultFunctionResolver stddevSamp() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> stddevSample(arguments, DOUBLE)) .build()); } @@ -218,7 +218,7 @@ private static DefaultFunctionResolver stddevPop() { functionName, new ImmutableMap.Builder() .put( - new FunctionSignature(functionName, singletonList(DOUBLE)), + new FunctionSignature(functionName, List.of(DOUBLE)), (functionProperties, arguments) -> stddevPopulation(arguments, DOUBLE)) .build()); } diff --git a/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java b/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java index f8a8d4773d..4d644b34c6 100644 --- a/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java +++ b/core/src/main/java/org/opensearch/sql/expression/function/FunctionDSL.java @@ -6,7 +6,6 @@ package org.opensearch.sql.expression.function; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import java.util.Arrays; import java.util.List; @@ -109,8 +108,7 @@ public String toString() { ExprType argsType) { return functionName -> { - FunctionSignature functionSignature = - new FunctionSignature(functionName, singletonList(argsType)); + FunctionSignature functionSignature = new FunctionSignature(functionName, List.of(argsType)); FunctionBuilder functionBuilder = (functionProperties, arguments) -> new FunctionExpression(functionName, arguments) { diff --git a/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java b/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java index 1c99af789a..b555c8c05c 100644 --- a/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java +++ b/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java @@ -5,7 +5,6 @@ package org.opensearch.sql.expression.text; -import static java.util.Collections.singletonList; import static org.opensearch.sql.data.type.ExprCoreType.ARRAY; import static org.opensearch.sql.data.type.ExprCoreType.INTEGER; import static org.opensearch.sql.data.type.ExprCoreType.STRING; @@ -176,7 +175,7 @@ private DefaultFunctionResolver concat() { concatFuncName, funcName -> Pair.of( - new FunctionSignature(concatFuncName, singletonList(ARRAY)), + new FunctionSignature(concatFuncName, List.of(ARRAY)), (funcProp, args) -> new FunctionExpression(funcName, args) { @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java index 40f70c422c..0cf5933eb3 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAD.java @@ -1,7 +1,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +23,7 @@ public class LogicalAD extends LogicalPlan { * @param arguments arguments of the algorithm */ public LogicalAD(LogicalPlan child, Map arguments) { - super(singletonList(child)); + super(List.of(child)); this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java index 450a4fe415..d40feb7dff 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalAggregation.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +24,7 @@ public class LogicalAggregation extends LogicalPlan { /** Constructor of LogicalAggregation. */ public LogicalAggregation( LogicalPlan child, List aggregatorList, List groupByList) { - super(singletonList(child)); + super(List.of(child)); this.aggregatorList = aggregatorList; this.groupByList = groupByList; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalDedupe.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalDedupe.java index 368dc3314f..33fbdfd00e 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalDedupe.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalDedupe.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -31,7 +29,7 @@ public LogicalDedupe( Integer allowedDuplication, Boolean keepEmpty, Boolean consecutive) { - super(singletonList(child)); + super(List.of(child)); this.dedupeList = dedupeList; this.allowedDuplication = allowedDuplication; this.keepEmpty = keepEmpty; diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java index 2a79a0ad44..b93b80202e 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalEval.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +26,7 @@ public class LogicalEval extends LogicalPlan { /** Constructor of LogicalEval. */ public LogicalEval(LogicalPlan child, List> expressions) { - super(singletonList(child)); + super(List.of(child)); this.expressions = expressions; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java index 7c2902c455..b28dab168c 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalFilter.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -21,7 +20,7 @@ public class LogicalFilter extends LogicalPlan { /** Constructor of LogicalFilter. */ public LogicalFilter(LogicalPlan child, Expression condition) { - super(singletonList(child)); + super(List.of(child)); this.condition = condition; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java index 1ad86fffd9..2f24681cdc 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalHighlight.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -24,7 +23,7 @@ public class LogicalHighlight extends LogicalPlan { /** Constructor of LogicalHighlight. */ public LogicalHighlight( LogicalPlan childPlan, Expression highlightField, Map arguments) { - super(singletonList(childPlan)); + super(List.of(childPlan)); this.highlightField = highlightField; this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java index 6933958976..90473ebc41 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalLimit.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -20,7 +19,7 @@ public class LogicalLimit extends LogicalPlan { /** Constructor of LogicalLimit. */ public LogicalLimit(LogicalPlan input, Integer limit, Integer offset) { - super(singletonList(input)); + super(List.of(input)); this.limit = limit; this.offset = offset; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java index dd7a5ae460..dd392be857 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalML.java @@ -1,7 +1,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -22,7 +21,7 @@ public class LogicalML extends LogicalPlan { * @param arguments arguments of the algorithm */ public LogicalML(LogicalPlan child, Map arguments) { - super(singletonList(child)); + super(List.of(child)); this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java index bfb1b4261d..74fc8d1c44 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalMLCommons.java @@ -1,7 +1,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,7 +24,7 @@ public class LogicalMLCommons extends LogicalPlan { * @param arguments arguments of the algorithm */ public LogicalMLCommons(LogicalPlan child, String algorithm, Map arguments) { - super(singletonList(child)); + super(List.of(child)); this.algorithm = algorithm; this.arguments = arguments; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java index 24d768865b..91eae51599 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; @@ -28,7 +26,7 @@ public LogicalNested( LogicalPlan childPlan, List> fields, List projectList) { - super(singletonList(childPlan)); + super(List.of(childPlan)); this.fields = fields; this.projectList = projectList; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java index 58576d2e59..37320f8428 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalProject.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -26,7 +24,7 @@ public LogicalProject( LogicalPlan child, List projectList, List namedParseExpressions) { - super(singletonList(child)); + super(List.of(child)); this.projectList = projectList; this.namedParseExpressions = namedParseExpressions; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java index 787350b5cb..17bb090f60 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRareTopN.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -32,7 +30,7 @@ public LogicalRareTopN( Integer noOfResults, List fieldList, List groupByList) { - super(singletonList(child)); + super(List.of(child)); this.commandType = commandType; this.noOfResults = noOfResults; this.fieldList = fieldList; diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java index a32fe0a2ab..d28b7b2195 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRemove.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import java.util.Set; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -22,7 +21,7 @@ public class LogicalRemove extends LogicalPlan { /** Constructor of LogicalRemove. */ public LogicalRemove(LogicalPlan child, Set removeList) { - super(singletonList(child)); + super(List.of(child)); this.removeList = removeList; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java index 7c117ce240..3826dcff58 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalRename.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import java.util.Map; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -22,7 +21,7 @@ public class LogicalRename extends LogicalPlan { /** Constructor of LogicalRename. */ public LogicalRename(LogicalPlan child, Map renameMap) { - super(singletonList(child)); + super(List.of(child)); this.renameMap = renameMap; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java index 17f6ff0a97..f5b9164e59 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalSort.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,7 +23,7 @@ public class LogicalSort extends LogicalPlan { /** Constructor of LogicalSort. */ public LogicalSort(LogicalPlan child, List> sortList) { - super(singletonList(child)); + super(List.of(child)); this.sortList = sortList; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java index 37310be391..d51db3a053 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWindow.java @@ -5,8 +5,7 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - +import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; @@ -28,7 +27,7 @@ public class LogicalWindow extends LogicalPlan { /** Constructor of logical window. */ public LogicalWindow( LogicalPlan child, NamedExpression windowFunction, WindowDefinition windowDefinition) { - super(singletonList(child)); + super(List.of(child)); this.windowFunction = windowFunction; this.windowDefinition = windowDefinition; } diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWrite.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWrite.java index 1f4d0ff108..76d75972d8 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWrite.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalWrite.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.logical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -27,7 +25,7 @@ public class LogicalWrite extends LogicalPlan { /** Construct a logical write with given child node, table and column name list. */ public LogicalWrite(LogicalPlan child, Table table, List columns) { - super(singletonList(child)); + super(List.of(child)); this.table = table; this.columns = columns; } diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java index 9103c3e4a6..c853788501 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/AggregationOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import java.util.Iterator; import java.util.List; import lombok.EqualsAndHashCode; @@ -60,7 +58,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java index 816ada3b10..73a2fb5aa1 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/DedupeOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import com.google.common.collect.ImmutableList; import java.util.List; import java.util.Map; @@ -79,7 +77,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java index e458b20211..14c9e4e8a6 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/EvalOperator.java @@ -5,7 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; import static org.opensearch.sql.data.type.ExprCoreType.STRUCT; import static org.opensearch.sql.expression.env.Environment.extendEnv; @@ -50,7 +49,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java index 291b267484..02cfd127e7 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/FilterOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -37,7 +35,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java index 92f463b742..65092cd7a5 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java @@ -5,7 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; import static java.util.stream.Collectors.mapping; import static java.util.stream.Collectors.toList; @@ -80,7 +79,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java index ccde753530..84e7c833eb 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/ProjectOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import java.io.IOException; @@ -43,7 +41,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java index dac850ba3b..c1c6a122a2 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/RareTopNOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.Streams; @@ -85,7 +83,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java index 23a562aca8..bd2b2c91fc 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/RemoveOperator.java @@ -5,7 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; import static org.opensearch.sql.data.type.ExprCoreType.STRUCT; import com.google.common.collect.ImmutableMap; @@ -49,7 +48,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java index 7195d15106..1039646563 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/RenameOperator.java @@ -5,7 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; import static org.opensearch.sql.data.type.ExprCoreType.STRUCT; import com.google.common.collect.ImmutableMap; @@ -56,7 +55,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java index 1a5887374b..468ebf9b31 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/SortOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import java.util.Comparator; import java.util.Iterator; import java.util.List; @@ -64,7 +62,7 @@ public void open() { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java index 27813450b7..97d31cb4d4 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/TakeOrderedOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import com.google.common.collect.Ordering; import java.util.Iterator; import java.util.List; @@ -74,7 +72,7 @@ public void open() { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java index eb962cb537..16f76b776f 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/WindowOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterators; import com.google.common.collect.PeekingIterator; @@ -63,7 +61,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } @Override diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java b/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java index 36455bf32c..5307947df7 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/collector/MetricCollector.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.physical.collector; -import static java.util.Collections.singletonList; - import java.util.AbstractMap; import java.util.LinkedHashMap; import java.util.List; @@ -58,6 +56,6 @@ public void collect(BindingTuple input) { public List results() { LinkedHashMap map = new LinkedHashMap<>(); aggregators.forEach(agg -> map.put(agg.getKey().getName(), agg.getValue().result())); - return singletonList(ExprTupleValue.fromExprValueMap(map)); + return List.of(ExprTupleValue.fromExprValueMap(map)); } } diff --git a/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java b/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java index 504fad9f30..9a003303a7 100644 --- a/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java +++ b/core/src/main/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssigner.java @@ -5,8 +5,6 @@ package org.opensearch.sql.planner.streaming.windowing.assigner; -import static java.util.Collections.singletonList; - import com.google.common.base.Preconditions; import java.util.List; import org.opensearch.sql.planner.streaming.windowing.Window; @@ -32,6 +30,6 @@ public TumblingWindowAssigner(long windowSize) { @Override public List assign(long timestamp) { long startTime = DateTimeUtils.getWindowStartTime(timestamp, windowSize); - return singletonList(new Window(startTime, startTime + windowSize)); + return List.of(new Window(startTime, startTime + windowSize)); } } diff --git a/core/src/main/java/org/opensearch/sql/storage/write/TableWriteBuilder.java b/core/src/main/java/org/opensearch/sql/storage/write/TableWriteBuilder.java index 1a430fc049..dfd49e94f3 100644 --- a/core/src/main/java/org/opensearch/sql/storage/write/TableWriteBuilder.java +++ b/core/src/main/java/org/opensearch/sql/storage/write/TableWriteBuilder.java @@ -5,8 +5,7 @@ package org.opensearch.sql.storage.write; -import static java.util.Collections.singletonList; - +import java.util.List; import org.opensearch.sql.planner.logical.LogicalPlan; import org.opensearch.sql.planner.logical.LogicalPlanNodeVisitor; import org.opensearch.sql.planner.physical.PhysicalPlan; @@ -21,7 +20,7 @@ public abstract class TableWriteBuilder extends LogicalPlan { /** Construct table write builder with child node. */ public TableWriteBuilder(LogicalPlan child) { - super(singletonList(child)); + super(List.of(child)); } /** diff --git a/core/src/main/java/org/opensearch/sql/storage/write/TableWriteOperator.java b/core/src/main/java/org/opensearch/sql/storage/write/TableWriteOperator.java index 82607eaa65..b11eb35f0e 100644 --- a/core/src/main/java/org/opensearch/sql/storage/write/TableWriteOperator.java +++ b/core/src/main/java/org/opensearch/sql/storage/write/TableWriteOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.storage.write; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.RequiredArgsConstructor; import org.opensearch.sql.planner.physical.PhysicalPlan; @@ -30,7 +28,7 @@ public R accept(PhysicalPlanNodeVisitor visitor, C context) { @Override public List getChild() { - return singletonList(input); + return List.of(input); } /** diff --git a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java index 53a5a28152..0a0f484dd0 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java +++ b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.analysis; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -894,7 +893,7 @@ public void remove_source() { DSL.ref("double_value", DOUBLE)), AstDSL.projectWithArg( AstDSL.relation("schema"), - singletonList(argument("exclude", booleanLiteral(true))), + List.of(argument("exclude", booleanLiteral(true))), AstDSL.field("integer_value"), AstDSL.field("double_value"))); } @@ -1041,8 +1040,8 @@ public void window_function() { "window_function", AstDSL.window( AstDSL.function("row_number"), - singletonList(AstDSL.qualifiedName("string_value")), - singletonList( + List.of(AstDSL.qualifiedName("string_value")), + List.of( ImmutablePair.of(DEFAULT_ASC, AstDSL.qualifiedName("integer_value"))))))); } diff --git a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java index c0ff667efc..3548cffef5 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java +++ b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java @@ -5,7 +5,6 @@ package org.opensearch.sql.analysis; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.opensearch.sql.analysis.DataSourceSchemaIdentifierNameResolver.DEFAULT_DATASOURCE_NAME; import static org.opensearch.sql.data.type.ExprCoreType.LONG; @@ -61,7 +60,7 @@ protected StorageEngine prometheusStorageEngine() { return new StorageEngine() { @Override public Collection getFunctions() { - return singletonList( + return List.of( new FunctionResolver() { @Override diff --git a/core/src/test/java/org/opensearch/sql/analysis/SelectExpressionAnalyzerTest.java b/core/src/test/java/org/opensearch/sql/analysis/SelectExpressionAnalyzerTest.java index 8898b0b7db..590f18f96f 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/SelectExpressionAnalyzerTest.java +++ b/core/src/test/java/org/opensearch/sql/analysis/SelectExpressionAnalyzerTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.analysis; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doAnswer; @@ -77,11 +76,11 @@ protected List analyze(UnresolvedExpression unresolvedExpressio .when(optimizer) .optimize(any(), any()); return new SelectExpressionAnalyzer(expressionAnalyzer) - .analyze(singletonList(unresolvedExpression), analysisContext, optimizer); + .analyze(List.of(unresolvedExpression), analysisContext, optimizer); } protected void assertAnalyzeEqual( NamedExpression expected, UnresolvedExpression unresolvedExpression) { - assertEquals(singletonList(expected), analyze(unresolvedExpression)); + assertEquals(List.of(expected), analyze(unresolvedExpression)); } } diff --git a/core/src/test/java/org/opensearch/sql/executor/ExplainTest.java b/core/src/test/java/org/opensearch/sql/executor/ExplainTest.java index eaeae07242..776a69bc5c 100644 --- a/core/src/test/java/org/opensearch/sql/executor/ExplainTest.java +++ b/core/src/test/java/org/opensearch/sql/executor/ExplainTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.executor; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.opensearch.sql.ast.tree.RareTopN.CommandType.TOP; import static org.opensearch.sql.ast.tree.Sort.SortOption.DEFAULT_ASC; @@ -78,11 +77,11 @@ void can_explain_project_filter_table_scan() { new ExplainResponseNode( "ProjectOperator", Map.of("fields", "[name, age]"), - singletonList( + List.of( new ExplainResponseNode( "FilterOperator", Map.of("conditions", "and(=(balance, 10000), >(age, 30))"), - singletonList(tableScan.explainNode()))))), + List.of(tableScan.explainNode()))))), explain.apply(plan)); } @@ -101,7 +100,7 @@ void can_explain_aggregations() { Map.of( "aggregators", "[avg(balance)]", "groupBy", "[state]"), - singletonList(tableScan.explainNode()))), + List.of(tableScan.explainNode()))), explain.apply(plan)); } @@ -115,7 +114,7 @@ void can_explain_rare_top_n() { new ExplainResponseNode( "RareTopNOperator", Map.of("commandType", TOP, "noOfResults", 10, "fields", "[state]", "groupBy", "[]"), - singletonList(tableScan.explainNode()))), + List.of(tableScan.explainNode()))), explain.apply(plan)); } @@ -145,7 +144,7 @@ void can_explain_window() { Map.of( "sortOrder", "ASC", "nullOrder", "NULL_FIRST")))), - singletonList(tableScan.explainNode()))), + List.of(tableScan.explainNode()))), explain.apply(plan)); } @@ -171,15 +170,15 @@ void can_explain_other_operators() { new ExplainResponseNode( "RemoveOperator", Map.of("removeList", "[state]"), - singletonList( + List.of( new ExplainResponseNode( "RenameOperator", Map.of("mapping", Map.of("state", "s")), - singletonList( + List.of( new ExplainResponseNode( "EvalOperator", Map.of("expressions", Map.of("age", "+(age, 2)")), - singletonList( + List.of( new ExplainResponseNode( "DedupeOperator", Map.of( @@ -191,7 +190,7 @@ void can_explain_other_operators() { false, "consecutive", false), - singletonList( + List.of( new ExplainResponseNode( "SortOperator", Map.of( @@ -201,7 +200,7 @@ void can_explain_other_operators() { Map.of( "sortOrder", "ASC", "nullOrder", "NULL_FIRST"))), - singletonList( + List.of( new ExplainResponseNode( "ValuesOperator", Map.of("values", List.of(values)), @@ -217,7 +216,7 @@ void can_explain_limit() { new ExplainResponseNode( "LimitOperator", Map.of("limit", 10, "offset", 5), - singletonList(tableScan.explainNode()))), + List.of(tableScan.explainNode()))), explain.apply(plan)); } @@ -237,7 +236,7 @@ void can_explain_takeOrdered() { 5, "sortList", Map.of("a", Map.of("sortOrder", "ASC", "nullOrder", "NULL_FIRST"))), - singletonList(tableScan.explainNode()))), + List.of(tableScan.explainNode()))), explain.apply(plan)); } @@ -252,7 +251,7 @@ void can_explain_nested() { new ExplainResponseNode( "NestedOperator", Map.of("nested", Set.of("message.info", "message")), - singletonList(tableScan.explainNode()))), + List.of(tableScan.explainNode()))), explain.apply(plan)); } diff --git a/core/src/test/java/org/opensearch/sql/expression/ExpressionNodeVisitorTest.java b/core/src/test/java/org/opensearch/sql/expression/ExpressionNodeVisitorTest.java index 3300ca374e..d77f484248 100644 --- a/core/src/test/java/org/opensearch/sql/expression/ExpressionNodeVisitorTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/ExpressionNodeVisitorTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.expression; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.opensearch.sql.data.type.ExprCoreType.INTEGER; @@ -38,7 +37,7 @@ void should_return_null_by_default() { assertNull(DSL.abs(literal(-10)).accept(visitor, null)); assertNull(DSL.sum(literal(10)).accept(visitor, null)); assertNull( - named("avg", new AvgAggregator(singletonList(ref("age", INTEGER)), INTEGER)) + named("avg", new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER)) .accept(visitor, null)); assertNull(new CaseClause(ImmutableList.of(), null).accept(visitor, null)); assertNull(new WhenClause(literal("test"), literal(10)).accept(visitor, null)); diff --git a/core/src/test/java/org/opensearch/sql/expression/function/BuiltinFunctionRepositoryTest.java b/core/src/test/java/org/opensearch/sql/expression/function/BuiltinFunctionRepositoryTest.java index 17f63d7215..6fc2d02191 100644 --- a/core/src/test/java/org/opensearch/sql/expression/function/BuiltinFunctionRepositoryTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/function/BuiltinFunctionRepositoryTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.expression.function; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -98,7 +97,7 @@ void compile_datasource_defined_function() { repo.compile( functionProperties, - singletonList(dataSourceFunctionResolver), + List.of(dataSourceFunctionResolver), mockFunctionName, List.of(mockExpression)); verify(functionExpressionBuilder, times(1)).apply(eq(functionProperties), any()); diff --git a/core/src/test/java/org/opensearch/sql/planner/DefaultImplementorTest.java b/core/src/test/java/org/opensearch/sql/planner/DefaultImplementorTest.java index a58773fae4..dd5572f73a 100644 --- a/core/src/test/java/org/opensearch/sql/planner/DefaultImplementorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/DefaultImplementorTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.planner; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -191,8 +190,8 @@ public void visitWindowOperator_should_return_PhysicalWindowOperator() { NamedExpression windowFunction = named(new RowNumberFunction()); WindowDefinition windowDefinition = new WindowDefinition( - singletonList(ref("state", STRING)), - singletonList(ImmutablePair.of(Sort.SortOption.DEFAULT_DESC, ref("age", INTEGER)))); + List.of(ref("state", STRING)), + List.of(ImmutablePair.of(Sort.SortOption.DEFAULT_DESC, ref("age", INTEGER)))); NamedExpression[] projectList = { named("state", ref("state", STRING)), named("row_number", ref("row_number", INTEGER)) diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/AggregationOperatorTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/AggregationOperatorTest.java index d454469ba2..feff12015a 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/AggregationOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/AggregationOperatorTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.planner.physical; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsInRelativeOrder; @@ -39,7 +38,7 @@ public void sum_without_groups() { PhysicalPlan plan = new AggregationOperator( new TestScan(), - singletonList(DSL.named("sum(response)", DSL.sum(DSL.ref("response", INTEGER)))), + List.of(DSL.named("sum(response)", DSL.sum(DSL.ref("response", INTEGER)))), emptyList()); List result = execute(plan); assertEquals(1, result.size()); @@ -53,8 +52,8 @@ public void avg_with_one_groups() { PhysicalPlan plan = new AggregationOperator( new TestScan(), - singletonList(DSL.named("avg(response)", DSL.avg(DSL.ref("response", INTEGER)))), - singletonList(DSL.named("action", DSL.ref("action", STRING)))); + List.of(DSL.named("avg(response)", DSL.avg(DSL.ref("response", INTEGER)))), + List.of(DSL.named("action", DSL.ref("action", STRING)))); List result = execute(plan); assertEquals(2, result.size()); assertThat( @@ -69,7 +68,7 @@ public void avg_with_two_groups() { PhysicalPlan plan = new AggregationOperator( new TestScan(), - singletonList(DSL.named("avg(response)", DSL.avg(DSL.ref("response", INTEGER)))), + List.of(DSL.named("avg(response)", DSL.avg(DSL.ref("response", INTEGER)))), Arrays.asList( DSL.named("action", DSL.ref("action", STRING)), DSL.named("ip", DSL.ref("ip", STRING)))); @@ -91,8 +90,8 @@ public void sum_with_one_groups() { PhysicalPlan plan = new AggregationOperator( new TestScan(), - singletonList(DSL.named("sum(response)", DSL.sum(DSL.ref("response", INTEGER)))), - singletonList(DSL.named("action", DSL.ref("action", STRING)))); + List.of(DSL.named("sum(response)", DSL.sum(DSL.ref("response", INTEGER)))), + List.of(DSL.named("action", DSL.ref("action", STRING)))); List result = execute(plan); assertEquals(2, result.size()); assertThat( @@ -107,8 +106,8 @@ public void millisecond_span() { PhysicalPlan plan = new AggregationOperator( testScan(datetimeInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("second", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("second", TIMESTAMP)))), + List.of( DSL.named( "span", DSL.span(DSL.ref("second", TIMESTAMP), DSL.literal(6 * 1000), "ms")))); List result = execute(plan); @@ -128,8 +127,8 @@ public void second_span() { PhysicalPlan plan = new AggregationOperator( testScan(datetimeInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("second", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("second", TIMESTAMP)))), + List.of( DSL.named("span", DSL.span(DSL.ref("second", TIMESTAMP), DSL.literal(6), "s")))); List result = execute(plan); assertEquals(2, result.size()); @@ -148,8 +147,8 @@ public void minute_span() { PhysicalPlan plan = new AggregationOperator( testScan(datetimeInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("minute", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("minute", TIMESTAMP)))), + List.of( DSL.named("span", DSL.span(DSL.ref("minute", TIMESTAMP), DSL.literal(5), "m")))); List result = execute(plan); assertEquals(3, result.size()); @@ -167,9 +166,8 @@ public void minute_span() { plan = new AggregationOperator( testScan(datetimeInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("hour", TIME)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("hour", TIME), DSL.literal(30), "m")))); + List.of(DSL.named("count", DSL.count(DSL.ref("hour", TIME)))), + List.of(DSL.named("span", DSL.span(DSL.ref("hour", TIME), DSL.literal(30), "m")))); result = execute(plan); assertEquals(4, result.size()); assertThat( @@ -190,8 +188,8 @@ public void hour_span() { PhysicalPlan plan = new AggregationOperator( testScan(datetimeInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("hour", TIME)))), - singletonList(DSL.named("span", DSL.span(DSL.ref("hour", TIME), DSL.literal(1), "h")))); + List.of(DSL.named("count", DSL.count(DSL.ref("hour", TIME)))), + List.of(DSL.named("span", DSL.span(DSL.ref("hour", TIME), DSL.literal(1), "h")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -210,8 +208,8 @@ public void day_span() { PhysicalPlan plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count(day)", DSL.count(DSL.ref("day", DATE)))), - singletonList(DSL.named("span", DSL.span(DSL.ref("day", DATE), DSL.literal(1), "d")))); + List.of(DSL.named("count(day)", DSL.count(DSL.ref("day", DATE)))), + List.of(DSL.named("span", DSL.span(DSL.ref("day", DATE), DSL.literal(1), "d")))); List result = execute(plan); assertEquals(4, result.size()); assertThat( @@ -229,9 +227,8 @@ public void day_span() { plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("month", DATE)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("month", DATE), DSL.literal(30), "d")))); + List.of(DSL.named("count", DSL.count(DSL.ref("month", DATE)))), + List.of(DSL.named("span", DSL.span(DSL.ref("month", DATE), DSL.literal(30), "d")))); result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -250,9 +247,8 @@ public void week_span() { PhysicalPlan plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("month", DATE)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("month", DATE), DSL.literal(5), "w")))); + List.of(DSL.named("count", DSL.count(DSL.ref("month", DATE)))), + List.of(DSL.named("span", DSL.span(DSL.ref("month", DATE), DSL.literal(5), "w")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -271,9 +267,8 @@ public void month_span() { PhysicalPlan plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("month", DATE)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("month", DATE), DSL.literal(1), "M")))); + List.of(DSL.named("count", DSL.count(DSL.ref("month", DATE)))), + List.of(DSL.named("span", DSL.span(DSL.ref("month", DATE), DSL.literal(1), "M")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -289,8 +284,8 @@ public void month_span() { plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("quarter", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("quarter", TIMESTAMP)))), + List.of( DSL.named("span", DSL.span(DSL.ref("quarter", TIMESTAMP), DSL.literal(2), "M")))); result = execute(plan); assertEquals(4, result.size()); @@ -310,8 +305,8 @@ public void month_span() { plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("year", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("year", TIMESTAMP)))), + List.of( DSL.named( "span", DSL.span(DSL.ref("year", TIMESTAMP), DSL.literal(10 * 12), "M")))); result = execute(plan); @@ -333,8 +328,8 @@ public void quarter_span() { PhysicalPlan plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("quarter", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("quarter", TIMESTAMP)))), + List.of( DSL.named("span", DSL.span(DSL.ref("quarter", TIMESTAMP), DSL.literal(2), "q")))); List result = execute(plan); assertEquals(2, result.size()); @@ -350,8 +345,8 @@ public void quarter_span() { plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("year", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("year", TIMESTAMP)))), + List.of( DSL.named("span", DSL.span(DSL.ref("year", TIMESTAMP), DSL.literal(10 * 4), "q")))); result = execute(plan); assertEquals(3, result.size()); @@ -372,9 +367,8 @@ public void year_span() { PhysicalPlan plan = new AggregationOperator( testScan(dateInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("year", TIMESTAMP)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("year", TIMESTAMP), DSL.literal(10), "y")))); + List.of(DSL.named("count", DSL.count(DSL.ref("year", TIMESTAMP)))), + List.of(DSL.named("span", DSL.span(DSL.ref("year", TIMESTAMP), DSL.literal(10), "y")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -394,9 +388,8 @@ public void integer_field() { PhysicalPlan plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("integer", INTEGER)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("integer", INTEGER), DSL.literal(1), "")))); + List.of(DSL.named("count", DSL.count(DSL.ref("integer", INTEGER)))), + List.of(DSL.named("span", DSL.span(DSL.ref("integer", INTEGER), DSL.literal(1), "")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -409,8 +402,8 @@ public void integer_field() { plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("integer", INTEGER)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("integer", INTEGER)))), + List.of( DSL.named("span", DSL.span(DSL.ref("integer", INTEGER), DSL.literal(1.5), "")))); result = execute(plan); assertEquals(3, result.size()); @@ -427,8 +420,8 @@ public void long_field() { PhysicalPlan plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("long", LONG)))), - singletonList(DSL.named("span", DSL.span(DSL.ref("long", LONG), DSL.literal(1), "")))); + List.of(DSL.named("count", DSL.count(DSL.ref("long", LONG)))), + List.of(DSL.named("span", DSL.span(DSL.ref("long", LONG), DSL.literal(1), "")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -441,9 +434,8 @@ public void long_field() { plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("long", LONG)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("long", LONG), DSL.literal(1.5), "")))); + List.of(DSL.named("count", DSL.count(DSL.ref("long", LONG)))), + List.of(DSL.named("span", DSL.span(DSL.ref("long", LONG), DSL.literal(1.5), "")))); result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -459,9 +451,8 @@ public void float_field() { PhysicalPlan plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("float", FLOAT)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("float", FLOAT), DSL.literal(1), "")))); + List.of(DSL.named("count", DSL.count(DSL.ref("float", FLOAT)))), + List.of(DSL.named("span", DSL.span(DSL.ref("float", FLOAT), DSL.literal(1), "")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -474,9 +465,8 @@ public void float_field() { plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("float", FLOAT)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("float", FLOAT), DSL.literal(1.5), "")))); + List.of(DSL.named("count", DSL.count(DSL.ref("float", FLOAT)))), + List.of(DSL.named("span", DSL.span(DSL.ref("float", FLOAT), DSL.literal(1.5), "")))); result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -492,9 +482,8 @@ public void double_field() { PhysicalPlan plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("double", DOUBLE)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("double", DOUBLE), DSL.literal(1), "")))); + List.of(DSL.named("count", DSL.count(DSL.ref("double", DOUBLE)))), + List.of(DSL.named("span", DSL.span(DSL.ref("double", DOUBLE), DSL.literal(1), "")))); List result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -507,9 +496,8 @@ public void double_field() { plan = new AggregationOperator( testScan(numericInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("double", DOUBLE)))), - singletonList( - DSL.named("span", DSL.span(DSL.ref("double", DOUBLE), DSL.literal(1.5), "")))); + List.of(DSL.named("count", DSL.count(DSL.ref("double", DOUBLE)))), + List.of(DSL.named("span", DSL.span(DSL.ref("double", DOUBLE), DSL.literal(1.5), "")))); result = execute(plan); assertEquals(3, result.size()); assertThat( @@ -525,7 +513,7 @@ public void twoBucketsSpanAndLong() { PhysicalPlan plan = new AggregationOperator( testScan(compoundInputs), - singletonList(DSL.named("max", DSL.max(DSL.ref("errors", INTEGER)))), + List.of(DSL.named("max", DSL.max(DSL.ref("errors", INTEGER)))), Arrays.asList( DSL.named("span", DSL.span(DSL.ref("day", DATE), DSL.literal(1), "d")), DSL.named("region", DSL.ref("region", STRING)))); @@ -550,7 +538,7 @@ public void twoBucketsSpanAndLong() { plan = new AggregationOperator( testScan(compoundInputs), - singletonList(DSL.named("max", DSL.max(DSL.ref("errors", INTEGER)))), + List.of(DSL.named("max", DSL.max(DSL.ref("errors", INTEGER)))), Arrays.asList( DSL.named("span", DSL.span(DSL.ref("day", DATE), DSL.literal(1), "d")), DSL.named("region", DSL.ref("region", STRING)), @@ -637,7 +625,7 @@ public void aggregate_with_two_groups_with_windowing() { PhysicalPlan plan = new AggregationOperator( testScan(compoundInputs), - singletonList(DSL.named("sum", DSL.sum(DSL.ref("errors", INTEGER)))), + List.of(DSL.named("sum", DSL.sum(DSL.ref("errors", INTEGER)))), Arrays.asList( DSL.named("host", DSL.ref("host", STRING)), DSL.named("span", DSL.span(DSL.ref("day", DATE), DSL.literal(1), "d")))); @@ -689,7 +677,7 @@ public void aggregate_with_three_groups_with_windowing() { PhysicalPlan plan = new AggregationOperator( testScan(compoundInputs), - singletonList(DSL.named("sum", DSL.sum(DSL.ref("errors", INTEGER)))), + List.of(DSL.named("sum", DSL.sum(DSL.ref("errors", INTEGER)))), Arrays.asList( DSL.named("host", DSL.ref("host", STRING)), DSL.named("span", DSL.span(DSL.ref("day", DATE), DSL.literal(1), "d")), @@ -749,8 +737,8 @@ public void copyOfAggregationOperatorShouldSame() { AggregationOperator plan = new AggregationOperator( testScan(datetimeInputs), - singletonList(DSL.named("count", DSL.count(DSL.ref("second", TIMESTAMP)))), - singletonList( + List.of(DSL.named("count", DSL.count(DSL.ref("second", TIMESTAMP)))), + List.of( DSL.named( "span", DSL.span(DSL.ref("second", TIMESTAMP), DSL.literal(6 * 1000), "ms")))); AggregationOperator copy = diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/RareTopNOperatorTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/RareTopNOperatorTest.java index 70e2ba1866..16779d2556 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/RareTopNOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/RareTopNOperatorTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.planner.physical; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -28,7 +27,7 @@ public void rare_without_group() { new RareTopNOperator( new TestScan(), CommandType.RARE, - singletonList(DSL.ref("action", ExprCoreType.STRING)), + List.of(DSL.ref("action", ExprCoreType.STRING)), emptyList()); List result = execute(plan); assertEquals(2, result.size()); @@ -45,8 +44,8 @@ public void rare_with_group() { new RareTopNOperator( new TestScan(), CommandType.RARE, - singletonList(DSL.ref("response", ExprCoreType.INTEGER)), - singletonList(DSL.ref("action", ExprCoreType.STRING))); + List.of(DSL.ref("response", ExprCoreType.INTEGER)), + List.of(DSL.ref("action", ExprCoreType.STRING))); List result = execute(plan); assertEquals(4, result.size()); assertThat( @@ -64,7 +63,7 @@ public void top_without_group() { new RareTopNOperator( new TestScan(), CommandType.TOP, - singletonList(DSL.ref("action", ExprCoreType.STRING)), + List.of(DSL.ref("action", ExprCoreType.STRING)), emptyList()); List result = execute(plan); assertEquals(2, result.size()); @@ -82,7 +81,7 @@ public void top_n_without_group() { new TestScan(), CommandType.TOP, 1, - singletonList(DSL.ref("action", ExprCoreType.STRING)), + List.of(DSL.ref("action", ExprCoreType.STRING)), emptyList()); List result = execute(plan); assertEquals(1, result.size()); @@ -97,8 +96,8 @@ public void top_n_with_group() { new TestScan(), CommandType.TOP, 1, - singletonList(DSL.ref("response", ExprCoreType.INTEGER)), - singletonList(DSL.ref("action", ExprCoreType.STRING))); + List.of(DSL.ref("response", ExprCoreType.INTEGER)), + List.of(DSL.ref("action", ExprCoreType.STRING))); List result = execute(plan); assertEquals(2, result.size()); assertThat( diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/RenameOperatorTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/RenameOperatorTest.java index fe55275e3b..47d557acd6 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/RenameOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/RenameOperatorTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.planner.physical; -import static java.util.Collections.singletonList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,8 +33,8 @@ public void avg_aggregation_rename() { new RenameOperator( new AggregationOperator( new TestScan(), - singletonList(DSL.named("avg(response)", DSL.avg(DSL.ref("response", INTEGER)))), - singletonList(DSL.named("action", DSL.ref("action", STRING)))), + List.of(DSL.named("avg(response)", DSL.avg(DSL.ref("response", INTEGER)))), + List.of(DSL.named("action", DSL.ref("action", STRING)))), ImmutableMap.of(DSL.ref("avg(response)", DOUBLE), DSL.ref("avg", DOUBLE))); List result = execute(plan); assertEquals(2, result.size()); diff --git a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java index 4869a4c8a8..3ce005ceb9 100644 --- a/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/streaming/windowing/assigner/TumblingWindowAssignerTest.java @@ -5,10 +5,10 @@ package org.opensearch.sql.planner.streaming.windowing.assigner; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import java.util.List; import org.junit.jupiter.api.Test; import org.opensearch.sql.planner.streaming.windowing.Window; @@ -19,9 +19,9 @@ void testAssignWindow() { long windowSize = 1000; TumblingWindowAssigner assigner = new TumblingWindowAssigner(windowSize); - assertEquals(singletonList(new Window(0, 1000)), assigner.assign(500)); - assertEquals(singletonList(new Window(1000, 2000)), assigner.assign(1999)); - assertEquals(singletonList(new Window(2000, 3000)), assigner.assign(2000)); + assertEquals(List.of(new Window(0, 1000)), assigner.assign(500)); + assertEquals(List.of(new Window(1000, 2000)), assigner.assign(1999)); + assertEquals(List.of(new Window(2000, 3000)), assigner.assign(2000)); } @Test diff --git a/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java b/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java index 3c28b14092..a2a00c7005 100644 --- a/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/storage/write/TableWriteOperatorTest.java @@ -5,10 +5,10 @@ package org.opensearch.sql.storage.write; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -68,6 +68,6 @@ public Boolean visitTableWrite(TableWriteOperator node, Object context) { @Test void testGetChild() { - assertEquals(singletonList(child), tableWrite.getChild()); + assertEquals(List.of(child), tableWrite.getChild()); } } diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/service/DataSourceServiceImplTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/service/DataSourceServiceImplTest.java index 84cb3d58a0..b2003aa6eb 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/service/DataSourceServiceImplTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/service/DataSourceServiceImplTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.datasources.service; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -120,10 +119,7 @@ void testGetDataSourceSuccessCase() { void testGetDataSourceWithAuthorizationFailure() { DataSourceMetadata dataSourceMetadata = metadata( - "test", - DataSourceType.OPENSEARCH, - singletonList("prometheus_access"), - ImmutableMap.of()); + "test", DataSourceType.OPENSEARCH, List.of("prometheus_access"), ImmutableMap.of()); doThrow( new SecurityException( "User is not authorized to access datasource test. User should be mapped to any of" @@ -326,7 +322,7 @@ void testRemovalOfAuthorizationInfo() { .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .build(); when(dataSourceMetadataStorage.getDataSourceMetadata("testDS")) .thenReturn(Optional.of(dataSourceMetadata)); @@ -351,7 +347,7 @@ void testRemovalOfAuthorizationInfoForAccessKeyAndSecretKye() { .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .build(); when(dataSourceMetadataStorage.getDataSourceMetadata("testDS")) .thenReturn(Optional.of(dataSourceMetadata)); @@ -378,7 +374,7 @@ void testRemovalOfAuthorizationInfoForGlueWithRoleARN() { .setName("testGlue") .setProperties(properties) .setConnector(DataSourceType.S3GLUE) - .setAllowedRoles(singletonList("glue_access")) + .setAllowedRoles(List.of("glue_access")) .build(); when(dataSourceMetadataStorage.getDataSourceMetadata("testGlue")) .thenReturn(Optional.of(dataSourceMetadata)); @@ -441,7 +437,7 @@ void testVerifyDataSourceAccessAndGetRawDataSourceMetadataWithDisabledData() { .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .setDataSourceStatus(DataSourceStatus.DISABLED) .build(); when(dataSourceMetadataStorage.getDataSourceMetadata("testDS")) @@ -468,7 +464,7 @@ void testVerifyDataSourceAccessAndGetRawDataSourceMetadata() { .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .setDataSourceStatus(DataSourceStatus.ACTIVE) .build(); when(dataSourceMetadataStorage.getDataSourceMetadata("testDS")) diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java index 0a363699cd..300f07caf9 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/storage/OpenSearchDataSourceMetadataStorageTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.datasources.storage; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.opensearch.sql.datasource.model.DataSourceStatus.ACTIVE; import static org.opensearch.sql.datasources.storage.OpenSearchDataSourceMetadataStorage.DATASOURCE_INDEX_NAME; @@ -713,7 +712,7 @@ private String getBasicDataSourceMetadataString() throws JsonProcessingException .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .build(); return serialize(dataSourceMetadata); } @@ -733,7 +732,7 @@ private String getAWSSigv4DataSourceMetadataString() throws JsonProcessingExcept .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .build(); return serialize(dataSourceMetadata); } @@ -750,7 +749,7 @@ private String getDataSourceMetadataStringWithBasicAuthentication() .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .build(); return serialize(dataSourceMetadata); } @@ -763,7 +762,7 @@ private String getDataSourceMetadataStringWithNoAuthentication() throws JsonProc .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .build(); return serialize(dataSourceMetadata); } @@ -778,7 +777,7 @@ private DataSourceMetadata getDataSourceMetadata() { .setName("testDS") .setProperties(properties) .setConnector(DataSourceType.PROMETHEUS) - .setAllowedRoles(singletonList("prometheus_access")) + .setAllowedRoles(List.of("prometheus_access")) .build(); } diff --git a/datasources/src/test/java/org/opensearch/sql/datasources/utils/DatasourceValidationUtilsTest.java b/datasources/src/test/java/org/opensearch/sql/datasources/utils/DatasourceValidationUtilsTest.java index e48ec0ffee..b736115c51 100644 --- a/datasources/src/test/java/org/opensearch/sql/datasources/utils/DatasourceValidationUtilsTest.java +++ b/datasources/src/test/java/org/opensearch/sql/datasources/utils/DatasourceValidationUtilsTest.java @@ -1,9 +1,9 @@ package org.opensearch.sql.datasources.utils; import static java.util.Collections.emptySet; -import static java.util.Collections.singletonList; import java.util.HashMap; +import java.util.List; import java.util.Set; import lombok.SneakyThrows; import org.apache.commons.lang3.RandomStringUtils; @@ -23,7 +23,7 @@ public void testValidateHost() { IllegalArgumentException.class, () -> DatasourceValidationUtils.validateHost( - "http://localhost:9090", singletonList("127.0.0.0/8"))); + "http://localhost:9090", List.of("127.0.0.0/8"))); Assertions.assertEquals( "Disallowed hostname in the uri. Validate with plugins.query.datasources.uri.hosts.denylist" + " config", @@ -36,7 +36,7 @@ public void testValidateHostWithSuccess() { Assertions.assertDoesNotThrow( () -> DatasourceValidationUtils.validateHost( - "http://localhost:9090", singletonList("192.168.0.0/8"))); + "http://localhost:9090", List.of("192.168.0.0/8"))); } @Test diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/PrettyFormatResponseIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/PrettyFormatResponseIT.java index f90b42cda2..03b6c3fb64 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/PrettyFormatResponseIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/PrettyFormatResponseIT.java @@ -5,7 +5,6 @@ package org.opensearch.sql.legacy; -import static java.util.Collections.singletonList; import static java.util.stream.Collectors.toSet; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.greaterThan; @@ -157,7 +156,7 @@ public void selectScore() throws IOException { "SELECT _score FROM %s WHERE SCORE(match_phrase(phrase, 'brown fox'))", TestsConstants.TEST_INDEX_PHRASE)); - List fields = singletonList("_score"); + List fields = List.of("_score"); assertContainsColumns(getSchema(response), fields); assertContainsData(getDataRows(response), fields); } @@ -277,7 +276,7 @@ public void groupBySingleField() throws IOException { String.format( Locale.ROOT, "SELECT * FROM %s GROUP BY age", TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = singletonList("age"); + List fields = List.of("age"); assertContainsColumns(getSchema(response), fields); assertContainsData(getDataRows(response), fields); } @@ -398,7 +397,7 @@ public void aggregationFunctionInSelectNoGroupBy() throws IOException { Locale.ROOT, "SELECT SUM(age) FROM %s", TestsConstants.TEST_INDEX_ACCOUNT)); String ageSum = "SUM(age)"; - assertContainsColumns(getSchema(response), singletonList(ageSum)); + assertContainsColumns(getSchema(response), List.of(ageSum)); JSONArray dataRows = getDataRows(response); for (int i = 0; i < dataRows.length(); i++) { @@ -433,7 +432,7 @@ public void aggregationFunctionInHaving() throws IOException { TestsConstants.TEST_INDEX_ACCOUNT)); String ageSum = "gender"; - assertContainsColumns(getSchema(response), singletonList(ageSum)); + assertContainsColumns(getSchema(response), List.of(ageSum)); JSONArray dataRows = getDataRows(response); assertEquals(1, dataRows.length()); @@ -555,7 +554,7 @@ public void joinQuerySelectOnlyOnOneTable() throws Exception { TestsConstants.TEST_INDEX_ACCOUNT, TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = singletonList("b1.age"); + List fields = List.of("b1.age"); assertContainsColumns(getSchema(response), fields); assertContainsData(getDataRows(response), fields); } diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java index 6d6b05a3e3..3e36ac966f 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java @@ -5,7 +5,6 @@ package org.opensearch.sql.legacy.executor.format; -import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import java.util.List; @@ -29,11 +28,11 @@ public DeleteResultSet(Client client, Delete query, Object queryResult) { } private List loadColumns() { - return singletonList(new Schema.Column(DELETED, null, Schema.Type.LONG)); + return List.of(new Schema.Column(DELETED, null, Schema.Type.LONG)); } private List loadRows() { - return singletonList(new DataRows.Row(loadDeletedData())); + return List.of(new DataRows.Row(loadDeletedData())); } private Map loadDeletedData() { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/expression/core/builder/UnaryExpressionBuilder.java b/legacy/src/main/java/org/opensearch/sql/legacy/expression/core/builder/UnaryExpressionBuilder.java index de726d7e19..d7682d7bf3 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/expression/core/builder/UnaryExpressionBuilder.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/expression/core/builder/UnaryExpressionBuilder.java @@ -5,8 +5,6 @@ package org.opensearch.sql.legacy.expression.core.builder; -import static java.util.Collections.singletonList; - import java.util.List; import lombok.RequiredArgsConstructor; import org.opensearch.sql.legacy.expression.core.Expression; @@ -32,7 +30,7 @@ public Expression build(List expressionList) { return new Expression() { @Override public ExprValue valueOf(BindingTuple tuple) { - return op.apply(singletonList(expression.valueOf(tuple))); + return op.apply(List.of(expression.valueOf(tuple))); } @Override diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SymbolSimilarityTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SymbolSimilarityTest.java index fbdcca2bb0..b2187ca8a8 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SymbolSimilarityTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SymbolSimilarityTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.legacy.antlr; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import java.util.Arrays; import java.util.List; @@ -27,7 +26,7 @@ public void noneCandidateShouldReturnTargetStringItself() { public void singleCandidateShouldReturnTheOnlyCandidate() { String target = "test"; String candidate = "hello"; - String mostSimilarSymbol = new SimilarSymbols(singletonList(candidate)).mostSimilarTo(target); + String mostSimilarSymbol = new SimilarSymbols(List.of(candidate)).mostSimilarTo(target); Assert.assertEquals(candidate, mostSimilarSymbol); } diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/GenericTypeTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/GenericTypeTest.java index 0bd8b526bb..500a61b464 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/GenericTypeTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/GenericTypeTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.legacy.antlr.semantic.types; -import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.DOUBLE; import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.INTEGER; @@ -16,6 +15,7 @@ import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.TYPE_ERROR; import static org.opensearch.sql.legacy.antlr.semantic.types.function.ScalarFunction.LOG; +import java.util.List; import org.junit.Test; /** Generic type test */ @@ -23,26 +23,26 @@ public class GenericTypeTest { @Test public void passNumberArgToLogShouldReturnNumber() { - assertEquals(DOUBLE, LOG.construct(singletonList(NUMBER))); + assertEquals(DOUBLE, LOG.construct(List.of(NUMBER))); } @Test public void passIntegerArgToLogShouldReturnDouble() { - assertEquals(DOUBLE, LOG.construct(singletonList(INTEGER))); + assertEquals(DOUBLE, LOG.construct(List.of(INTEGER))); } @Test public void passLongArgToLogShouldReturnDouble() { - assertEquals(DOUBLE, LOG.construct(singletonList(LONG))); + assertEquals(DOUBLE, LOG.construct(List.of(LONG))); } @Test public void passTextArgToLogShouldReturnTypeError() { - assertEquals(TYPE_ERROR, LOG.construct(singletonList(TEXT))); + assertEquals(TYPE_ERROR, LOG.construct(List.of(TEXT))); } @Test public void passKeywordArgToLogShouldReturnTypeError() { - assertEquals(TYPE_ERROR, LOG.construct(singletonList(KEYWORD))); + assertEquals(TYPE_ERROR, LOG.construct(List.of(KEYWORD))); } } diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/ProductTypeTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/ProductTypeTest.java index 5c87aabdee..6883cf75d9 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/ProductTypeTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/ProductTypeTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.legacy.antlr.semantic.types; -import static java.util.Collections.singletonList; import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.BOOLEAN; import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.INTEGER; import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.KEYWORD; @@ -13,6 +12,7 @@ import static org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType.STRING; import java.util.Arrays; +import java.util.List; import org.junit.Assert; import org.junit.Test; import org.opensearch.sql.legacy.antlr.semantic.types.special.Product; @@ -22,16 +22,16 @@ public class ProductTypeTest { @Test public void singleSameTypeInTwoProductsShouldPass() { - Product product1 = new Product(singletonList(INTEGER)); - Product product2 = new Product(singletonList(INTEGER)); + Product product1 = new Product(List.of(INTEGER)); + Product product2 = new Product(List.of(INTEGER)); Assert.assertTrue(product1.isCompatible(product2)); Assert.assertTrue(product2.isCompatible(product1)); } @Test public void singleCompatibleTypeInTwoProductsShouldPass() { - Product product1 = new Product(singletonList(NUMBER)); - Product product2 = new Product(singletonList(INTEGER)); + Product product1 = new Product(List.of(NUMBER)); + Product product2 = new Product(List.of(INTEGER)); Assert.assertTrue(product1.isCompatible(product2)); Assert.assertTrue(product2.isCompatible(product1)); } @@ -46,8 +46,8 @@ public void twoCompatibleTypesInTwoProductsShouldPass() { @Test public void incompatibleTypesInTwoProductsShouldFail() { - Product product1 = new Product(singletonList(BOOLEAN)); - Product product2 = new Product(singletonList(STRING)); + Product product1 = new Product(List.of(BOOLEAN)); + Product product2 = new Product(List.of(STRING)); Assert.assertFalse(product1.isCompatible(product2)); Assert.assertFalse(product2.isCompatible(product1)); } @@ -55,14 +55,14 @@ public void incompatibleTypesInTwoProductsShouldFail() { @Test public void compatibleButDifferentTypeNumberInTwoProductsShouldFail() { Product product1 = new Product(Arrays.asList(KEYWORD, INTEGER)); - Product product2 = new Product(singletonList(STRING)); + Product product2 = new Product(List.of(STRING)); Assert.assertFalse(product1.isCompatible(product2)); Assert.assertFalse(product2.isCompatible(product1)); } @Test public void baseTypeShouldBeIncompatibleWithProductType() { - Product product = new Product(singletonList(INTEGER)); + Product product = new Product(List.of(INTEGER)); Assert.assertFalse(INTEGER.isCompatible(product)); Assert.assertFalse(product.isCompatible(INTEGER)); } diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/executor/format/BindingTupleResultSetTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/executor/format/BindingTupleResultSetTest.java index 96210c7d8a..3c0cc4fdaa 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/executor/format/BindingTupleResultSetTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/executor/format/BindingTupleResultSetTest.java @@ -14,7 +14,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import org.hamcrest.Matcher; @@ -70,7 +69,7 @@ public void buildDataRowsFromBindingTupleIncludeDateShouldPass() { Arrays.asList( ColumnNode.builder().alias("dateValue").type(Schema.Type.DATE).build(), ColumnNode.builder().alias("gender").type(Schema.Type.TEXT).build()), - Collections.singletonList( + List.of( BindingTuple.from(ImmutableMap.of("dateValue", 1529712000000L, "gender", "m")))), containsInAnyOrder( rowContents( diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/ADOperator.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/ADOperator.java index f274e35811..803768ba66 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/ADOperator.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/ADOperator.java @@ -5,7 +5,6 @@ package org.opensearch.sql.opensearch.planner.physical; -import static java.util.Collections.singletonList; import static org.opensearch.sql.utils.MLCommonsConstants.ANOMALY_RATE; import static org.opensearch.sql.utils.MLCommonsConstants.ANOMALY_SCORE_THRESHOLD; import static org.opensearch.sql.utils.MLCommonsConstants.CATEGORY_FIELD; @@ -69,7 +68,7 @@ public void open() { List predictionResults = inputDataFrames.stream() .map(pair -> getMLPredictionResult(rcfType, mlAlgoParams, pair.getRight(), nodeClient)) - .collect(Collectors.toList()); + .toList(); Iterator> inputDataFramesIter = inputDataFrames.iterator(); Iterator predictionResultIter = predictionResults.iterator(); @@ -115,7 +114,7 @@ public ExprValue next() { @Override public List getChild() { - return singletonList(input); + return List.of(input); } protected MLAlgoParams convertArgumentToMLParameter(Map arguments) { diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java index 3ae0f43fce..10342f6d4d 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperator.java @@ -5,7 +5,6 @@ package org.opensearch.sql.opensearch.planner.physical; -import static java.util.Collections.singletonList; import static org.opensearch.ml.common.FunctionName.KMEANS; import static org.opensearch.sql.utils.MLCommonsConstants.CENTROIDS; import static org.opensearch.sql.utils.MLCommonsConstants.DISTANCE_TYPE; @@ -91,7 +90,7 @@ public ExprValue next() { @Override public List getChild() { - return singletonList(input); + return List.of(input); } protected MLAlgoParams convertArgumentToMLParameter( diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java index 00a28342ef..ecb486f39f 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/planner/physical/MLOperator.java @@ -5,8 +5,6 @@ package org.opensearch.sql.opensearch.planner.physical; -import static java.util.Collections.singletonList; - import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -99,7 +97,7 @@ public ExprValue next() { @Override public List getChild() { - return singletonList(input); + return List.of(input); } protected Map processArgs(Map arguments) { diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/response/agg/NoBucketAggregationParser.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/response/agg/NoBucketAggregationParser.java index 3a61915499..b3bdece816 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/response/agg/NoBucketAggregationParser.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/response/agg/NoBucketAggregationParser.java @@ -13,8 +13,6 @@ package org.opensearch.sql.opensearch.response.agg; -import static java.util.Collections.singletonList; - import java.util.Arrays; import java.util.List; import java.util.Map; @@ -35,6 +33,6 @@ public NoBucketAggregationParser(List metricParserList) { @Override public List> parse(Aggregations aggregations) { - return singletonList(metricsParser.parse(aggregations)); + return List.of(metricsParser.parse(aggregations)); } } diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java index 7f14cb1fe0..e46fdb0b81 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java @@ -5,8 +5,6 @@ package org.opensearch.sql.opensearch.storage.script.aggregation; -import static java.util.Collections.singletonList; - import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -78,7 +76,7 @@ public AggregationQueryBuilder(ExpressionSerializer serializer) { } else { GroupSortOrder groupSortOrder = new GroupSortOrder(sortList); return Pair.of( - singletonList( + List.of( AggregationBuilders.composite( "composite_buckets", bucketBuilder.build( diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperatorTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperatorTest.java index 6b76b37360..5573e55f32 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperatorTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLCommonsOperatorTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.opensearch.planner.physical; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -18,6 +17,7 @@ import com.google.common.collect.ImmutableMap; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.BeforeEach; @@ -81,7 +81,7 @@ void setUp() { DataFrame dataFrame = DataFrameBuilder.load( - singletonList( + List.of( ImmutableMap.builder() .put("result-k1", 2D) .put("result-k2", 1) diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java index f003de848d..f191489887 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.opensearch.planner.physical; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -22,6 +21,7 @@ import com.google.common.collect.ImmutableMap; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; @@ -87,7 +87,7 @@ void setUp(boolean isPredict) { DataFrame dataFrame = DataFrameBuilder.load( - singletonList( + List.of( ImmutableMap.builder() .put("result-k1", 2D) .put("result-k2", 1) diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/request/OpenSearchRequestBuilderTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/request/OpenSearchRequestBuilderTest.java index 1e6bb6b171..0d0b0c3e67 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/request/OpenSearchRequestBuilderTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/request/OpenSearchRequestBuilderTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.opensearch.request; -import static java.util.Collections.singletonList; import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; @@ -349,7 +348,7 @@ void test_push_down_query() { void test_push_down_aggregation() { AggregationBuilder aggBuilder = AggregationBuilders.composite( - "composite_buckets", singletonList(new TermsValuesSourceBuilder("longA"))); + "composite_buckets", List.of(new TermsValuesSourceBuilder("longA"))); OpenSearchAggregationResponseParser responseParser = new CompositeAggregationParser(new SingleValueParser("AVG(intA)")); requestBuilder.pushDownAggregation(Pair.of(List.of(aggBuilder), responseParser)); @@ -368,7 +367,7 @@ void test_push_down_aggregation() { void test_push_down_percentile_aggregation() { AggregationBuilder aggBuilder = AggregationBuilders.composite( - "composite_buckets", singletonList(new TermsValuesSourceBuilder("longA"))); + "composite_buckets", List.of(new TermsValuesSourceBuilder("longA"))); OpenSearchAggregationResponseParser responseParser = new CompositeAggregationParser(new SinglePercentileParser("PERCENTILE(intA, 50)")); requestBuilder.pushDownAggregation(Pair.of(List.of(aggBuilder), responseParser)); diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanOptimizationTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanOptimizationTest.java index b0769b950c..9dca693f24 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanOptimizationTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanOptimizationTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.opensearch.storage.scan; import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; @@ -642,7 +641,7 @@ private Runnable withAggregationPushedDown( CompositeAggregationBuilder aggBuilder = AggregationBuilders.composite( "composite_buckets", - singletonList( + List.of( new TermsValuesSourceBuilder(aggregation.groupBy) .field(aggregation.groupBy) .order(aggregation.sortBy.getSortOrder() == ASC ? "asc" : "desc") @@ -653,7 +652,7 @@ private Runnable withAggregationPushedDown( AggregationBuilders.avg(aggregation.aggregateName).field(aggregation.aggregateBy)) .size(AggregationQueryBuilder.AGGREGATION_BUCKET_SIZE); - List aggBuilders = singletonList(aggBuilder); + List aggBuilders = List.of(aggBuilder); OpenSearchAggregationResponseParser responseParser = new CompositeAggregationParser(new SingleValueParser(aggregation.aggregateName)); diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilderTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilderTest.java index 13769ef226..9bcf24c0c2 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilderTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilderTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.opensearch.storage.script.aggregation; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -281,7 +280,7 @@ void should_build_composite_aggregation_for_expression() { List.of( named( "avg(balance)", - new AvgAggregator(singletonList(DSL.abs(ref("balance", INTEGER))), INTEGER))), + new AvgAggregator(List.of(DSL.abs(ref("balance", INTEGER))), INTEGER))), List.of(named("age", DSL.asin(ref("age", INTEGER)))))); } @@ -339,7 +338,7 @@ void should_build_type_mapping_for_expression() { List.of( named( "avg(balance)", - new AvgAggregator(singletonList(DSL.abs(ref("balance", INTEGER))), INTEGER))), + new AvgAggregator(List.of(DSL.abs(ref("balance", INTEGER))), INTEGER))), List.of(named("age", DSL.asin(ref("age", INTEGER))))), containsInAnyOrder( map("avg(balance)", OpenSearchDataType.of(INTEGER)), diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilderTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilderTest.java index 8c6ff07083..bfdc2392b2 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilderTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilderTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.opensearch.storage.script.aggregation.dsl; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.when; @@ -335,11 +334,10 @@ void should_build_cardinality_aggregation() { + " }%n" + "}"), buildQuery( - singletonList( + List.of( named( "count(distinct name)", - new CountAggregator(singletonList(ref("name", STRING)), INTEGER) - .distinct(true))))); + new CountAggregator(List.of(ref("name", STRING)), INTEGER).distinct(true))))); } @Test @@ -369,10 +367,10 @@ void should_build_filtered_cardinality_aggregation() { + " }%n" + "}"), buildQuery( - singletonList( + List.of( named( "count(distinct name) filter(where age > 30)", - new CountAggregator(singletonList(ref("name", STRING)), INTEGER) + new CountAggregator(List.of(ref("name", STRING)), INTEGER) .condition(DSL.greater(ref("age", INTEGER), literal(30))) .distinct(true))))); } @@ -397,7 +395,7 @@ void should_build_top_hits_aggregation() { + " }%n" + "}"), buildQuery( - singletonList( + List.of( named( "take(name, 10)", new TakeAggregator( @@ -439,7 +437,7 @@ void should_build_filtered_top_hits_aggregation() { + " }%n" + "}"), buildQuery( - singletonList( + List.of( named( "take(name, 10) filter(where age > 30)", new TakeAggregator(ImmutableList.of(ref("name", STRING), literal(10)), ARRAY) @@ -452,11 +450,10 @@ void should_throw_exception_for_unsupported_distinct_aggregator() { IllegalStateException.class, () -> buildQuery( - singletonList( + List.of( named( "avg(distinct age)", - new AvgAggregator(singletonList(ref("name", STRING)), STRING) - .distinct(true)))), + new AvgAggregator(List.of(ref("name", STRING)), STRING).distinct(true)))), "unsupported distinct aggregator avg"); } diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/ExpressionFilterScriptTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/ExpressionFilterScriptTest.java index df754887cf..9ea3c72499 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/ExpressionFilterScriptTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/ExpressionFilterScriptTest.java @@ -7,7 +7,6 @@ import static java.util.Collections.emptyList; import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -238,7 +237,7 @@ private static class FakeScriptDocValues extends ScriptDocValues { @SuppressWarnings("unchecked") public FakeScriptDocValues(T value) { - this.values = (value instanceof List) ? (List) value : singletonList(value); + this.values = (value instanceof List) ? (List) value : List.of(value); } @Override diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/system/OpenSearchSystemIndexScanTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/system/OpenSearchSystemIndexScanTest.java index afe2e0b172..91d0800bc3 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/system/OpenSearchSystemIndexScanTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/system/OpenSearchSystemIndexScanTest.java @@ -5,12 +5,12 @@ package org.opensearch.sql.opensearch.storage.system; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; import static org.opensearch.sql.data.model.ExprValueUtils.stringValue; +import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -24,7 +24,7 @@ class OpenSearchSystemIndexScanTest { @Test public void queryData() { - when(request.search()).thenReturn(singletonList(stringValue("text"))); + when(request.search()).thenReturn(List.of(stringValue("text"))); final OpenSearchSystemIndexScan systemIndexScan = new OpenSearchSystemIndexScan(request); systemIndexScan.open(); diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/utils/Utils.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/utils/Utils.java index 75e27e58da..9a42cb089f 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/utils/Utils.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/utils/Utils.java @@ -5,8 +5,6 @@ package org.opensearch.sql.opensearch.utils; -import static java.util.Collections.singletonList; - import com.google.common.collect.ImmutableSet; import java.util.Arrays; import java.util.List; @@ -25,7 +23,7 @@ public class Utils { public static AvgAggregator avg(Expression expr, ExprCoreType type) { - return new AvgAggregator(singletonList(expr), type); + return new AvgAggregator(List.of(expr), type); } public static List agg(NamedAggregator... exprs) { @@ -38,7 +36,7 @@ public static List group(NamedExpression... exprs) { public static List> sort( Expression expr1, Sort.SortOption option1) { - return singletonList(Pair.of(option1, expr1)); + return List.of(Pair.of(option1, expr1)); } public static List> sort( diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java b/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java index 766edc42c0..db87e64430 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java @@ -5,7 +5,6 @@ package org.opensearch.sql.plugin; -import static java.util.Collections.singletonList; import static org.opensearch.sql.datasource.model.DataSourceMetadata.defaultOpenSearchDataSourceMetadata; import static org.opensearch.sql.spark.data.constants.SparkConstants.SPARK_REQUEST_BUFFER_INDEX_NAME; @@ -276,7 +275,7 @@ public ScheduledJobParser getJobParser() { @Override public List> getExecutorBuilders(Settings settings) { - return singletonList( + return List.of( new FixedExecutorBuilder( settings, AsyncRestExecutor.SQL_WORKER_THREAD_POOL_NAME, diff --git a/ppl/src/main/java/org/opensearch/sql/ppl/utils/ArgumentFactory.java b/ppl/src/main/java/org/opensearch/sql/ppl/utils/ArgumentFactory.java index 6e20d19820..c7e77651a8 100644 --- a/ppl/src/main/java/org/opensearch/sql/ppl/utils/ArgumentFactory.java +++ b/ppl/src/main/java/org/opensearch/sql/ppl/utils/ArgumentFactory.java @@ -5,7 +5,6 @@ package org.opensearch.sql.ppl.utils; -import static java.util.Collections.singletonList; import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.BooleanLiteralContext; import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.DedupCommandContext; import static org.opensearch.sql.ppl.antlr.parser.OpenSearchPPLParser.FieldsCommandContext; @@ -33,7 +32,7 @@ public class ArgumentFactory { * @return the list of arguments fetched from the fields command */ public static List getArgumentList(FieldsCommandContext ctx) { - return singletonList( + return List.of( ctx.MINUS() != null ? new Argument("exclude", new Literal(true, DataType.BOOLEAN)) : new Argument("exclude", new Literal(false, DataType.BOOLEAN))); @@ -109,7 +108,7 @@ public static List getArgumentList(SortFieldContext ctx) { * @return the list of arguments fetched from the top command */ public static List getArgumentList(TopCommandContext ctx) { - return singletonList( + return List.of( ctx.number != null ? new Argument("noOfResults", getArgumentValue(ctx.number)) : new Argument("noOfResults", new Literal(10, DataType.INTEGER))); @@ -122,7 +121,7 @@ public static List getArgumentList(TopCommandContext ctx) { * @return the list of argument with default number of results for the rare command */ public static List getArgumentList(RareCommandContext ctx) { - return singletonList(new Argument("noOfResults", new Literal(10, DataType.INTEGER))); + return List.of(new Argument("noOfResults", new Literal(10, DataType.INTEGER))); } /** diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/utils/UnresolvedPlanHelperTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/utils/UnresolvedPlanHelperTest.java index 887c655702..b86ab0cd59 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/utils/UnresolvedPlanHelperTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/utils/UnresolvedPlanHelperTest.java @@ -5,10 +5,10 @@ package org.opensearch.sql.ppl.utils; -import static java.util.Collections.singletonList; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.when; +import java.util.List; import junit.framework.TestCase; import org.hamcrest.Matchers; import org.junit.Test; @@ -47,7 +47,7 @@ public void dontAddProjectForProjectOperator() { Project project = Mockito.mock(Project.class); UnresolvedExpression expression = Mockito.mock(UnresolvedExpression.class); when(project.isExcluded()).thenReturn(false); - when(project.getProjectList()).thenReturn(singletonList(expression)); + when(project.getProjectList()).thenReturn(List.of(expression)); UnresolvedPlan plan = UnresolvedPlanHelper.addSelectAll(project); assertTrue(plan instanceof Project); diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/client/PrometheusClientImplTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/client/PrometheusClientImplTest.java index 8709cecba3..6dc6e11f0e 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/client/PrometheusClientImplTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/client/PrometheusClientImplTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.prometheus.client; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -154,13 +153,12 @@ void testGetAllMetrics() { Map> expected = new HashMap<>(); expected.put( "go_gc_duration_seconds", - singletonList( + List.of( new MetricMetadata( "summary", "A summary of the pause duration of garbage collection cycles.", ""))); expected.put( "go_goroutines", - singletonList( - new MetricMetadata("gauge", "Number of goroutines that currently exist.", ""))); + List.of(new MetricMetadata("gauge", "Number of goroutines that currently exist.", ""))); assertEquals(expected, response); RecordedRequest recordedRequest = mockWebServer.takeRequest(); verifyGetAllMetricsCall(recordedRequest); diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryRangeFunctionTableScanOperatorTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryRangeFunctionTableScanOperatorTest.java index 6345dcb1de..82234f5118 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryRangeFunctionTableScanOperatorTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/functions/scan/QueryRangeFunctionTableScanOperatorTest.java @@ -7,7 +7,6 @@ package org.opensearch.sql.prometheus.functions.scan; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -25,6 +24,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.LinkedHashMap; +import java.util.List; import lombok.SneakyThrows; import org.json.JSONObject; import org.junit.jupiter.api.Assertions; @@ -80,9 +80,8 @@ void testQueryResponseIterator() { put( TIMESTAMP, new ExprCollectionValue( - singletonList( - new ExprTimestampValue(Instant.ofEpochMilli(1435781430781L))))); - put(VALUE, new ExprCollectionValue(singletonList(new ExprDoubleValue(1)))); + List.of(new ExprTimestampValue(Instant.ofEpochMilli(1435781430781L))))); + put(VALUE, new ExprCollectionValue(List.of(new ExprDoubleValue(1)))); } }); @@ -105,9 +104,8 @@ void testQueryResponseIterator() { put( TIMESTAMP, new ExprCollectionValue( - singletonList( - new ExprTimestampValue(Instant.ofEpochMilli(1435781430781L))))); - put(VALUE, new ExprCollectionValue(singletonList(new ExprDoubleValue(0)))); + List.of(new ExprTimestampValue(Instant.ofEpochMilli(1435781430781L))))); + put(VALUE, new ExprCollectionValue(List.of(new ExprDoubleValue(0)))); } }); assertEquals(secondRow, queryRangeFunctionTableScanOperator.next()); diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/request/PrometheusListMetricsRequestTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/request/PrometheusListMetricsRequestTest.java index 8fff1c36d0..17f405df4b 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/request/PrometheusListMetricsRequestTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/request/PrometheusListMetricsRequestTest.java @@ -7,7 +7,6 @@ package org.opensearch.sql.prometheus.request; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.times; @@ -43,13 +42,12 @@ void testSearch() { Map> metricsResult = new HashMap<>(); metricsResult.put( "go_gc_duration_seconds", - singletonList( + List.of( new MetricMetadata( "summary", "A summary of the pause duration of garbage collection cycles.", ""))); metricsResult.put( "go_goroutines", - singletonList( - new MetricMetadata("gauge", "Number of goroutines that currently exist.", ""))); + List.of(new MetricMetadata("gauge", "Number of goroutines that currently exist.", ""))); when(prometheusClient.getAllMetrics()).thenReturn(metricsResult); PrometheusListMetricsRequest prometheusListMetricsRequest = new PrometheusListMetricsRequest( diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusMetricScanTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusMetricScanTest.java index 9b3c193250..02797b40e6 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusMetricScanTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusMetricScanTest.java @@ -5,7 +5,6 @@ package org.opensearch.sql.prometheus.storage; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -24,6 +23,7 @@ import java.io.IOException; import java.time.Instant; import java.util.LinkedHashMap; +import java.util.List; import lombok.SneakyThrows; import org.json.JSONObject; import org.junit.jupiter.api.Assertions; @@ -187,7 +187,7 @@ void testQueryResponseIteratorWithGivenPrometheusResponseWithBackQuotedFieldName prometheusResponseFieldNames.setValueType(LONG); prometheusResponseFieldNames.setTimestampFieldName(TIMESTAMP); prometheusResponseFieldNames.setGroupByList( - singletonList(DSL.named("`instance`", DSL.ref("instance", STRING)))); + List.of(DSL.named("`instance`", DSL.ref("instance", STRING)))); PrometheusMetricScan prometheusMetricScan = new PrometheusMetricScan(prometheusClient); prometheusMetricScan.setPrometheusResponseFieldNames(prometheusResponseFieldNames); prometheusMetricScan.getRequest().setPromQl(QUERY); diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java index e41b0a321e..9d34d28810 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/PrometheusStorageFactoryTest.java @@ -8,10 +8,10 @@ package org.opensearch.sql.prometheus.storage; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.mockito.Mockito.when; import java.util.HashMap; +import java.util.List; import lombok.SneakyThrows; import org.apache.commons.lang3.RandomStringUtils; import org.junit.jupiter.api.Assertions; @@ -217,7 +217,7 @@ void createDataSourceSuccessWithLocalhost() { @Test void createDataSourceWithHostnameNotMatchingWithAllowHostsConfig() { when(settings.getSettingValue(Settings.Key.DATASOURCES_URI_HOSTS_DENY_LIST)) - .thenReturn(singletonList("127.0.0.0/8")); + .thenReturn(List.of("127.0.0.0/8")); HashMap properties = new HashMap<>(); properties.put("prometheus.uri", "http://localhost:9090"); properties.put("prometheus.auth.type", "basicauth"); diff --git a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/system/PrometheusSystemTableScanTest.java b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/system/PrometheusSystemTableScanTest.java index e988a481a0..bb8ebe8207 100644 --- a/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/system/PrometheusSystemTableScanTest.java +++ b/prometheus/src/test/java/org/opensearch/sql/prometheus/storage/system/PrometheusSystemTableScanTest.java @@ -7,12 +7,12 @@ package org.opensearch.sql.prometheus.storage.system; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; import static org.opensearch.sql.data.model.ExprValueUtils.stringValue; +import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -26,7 +26,7 @@ public class PrometheusSystemTableScanTest { @Test public void queryData() { - when(request.search()).thenReturn(singletonList(stringValue("text"))); + when(request.search()).thenReturn(List.of(stringValue("text"))); final PrometheusSystemTableScan systemIndexScan = new PrometheusSystemTableScan(request); systemIndexScan.open(); diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java index af03429bac..5e2b17b393 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.protocol.response; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.fail; @@ -17,6 +16,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.Arrays; +import java.util.List; import org.junit.jupiter.api.Test; import org.opensearch.sql.executor.ExecutionEngine; import org.opensearch.sql.executor.pagination.Cursor; @@ -46,9 +46,7 @@ void size() { void columnNameTypes() { QueryResult response = new QueryResult( - schema, - singletonList(tupleValue(ImmutableMap.of("name", "John", "age", 20))), - Cursor.None); + schema, List.of(tupleValue(ImmutableMap.of("name", "John", "age", 20))), Cursor.None); assertEquals(ImmutableMap.of("name", "string", "age", "integer"), response.columnNameTypes()); } @@ -59,8 +57,7 @@ void columnNameTypesWithAlias() { new ExecutionEngine.Schema( ImmutableList.of(new ExecutionEngine.Schema.Column("name", "n", STRING))); QueryResult response = - new QueryResult( - schema, singletonList(tupleValue(ImmutableMap.of("n", "John"))), Cursor.None); + new QueryResult(schema, List.of(tupleValue(ImmutableMap.of("n", "John"))), Cursor.None); assertEquals(ImmutableMap.of("n", "string"), response.columnNameTypes()); } diff --git a/spark/src/main/java/org/opensearch/sql/spark/storage/SparkStorageEngine.java b/spark/src/main/java/org/opensearch/sql/spark/storage/SparkStorageEngine.java index 11d638457c..d2c69a7310 100644 --- a/spark/src/main/java/org/opensearch/sql/spark/storage/SparkStorageEngine.java +++ b/spark/src/main/java/org/opensearch/sql/spark/storage/SparkStorageEngine.java @@ -5,9 +5,8 @@ package org.opensearch.sql.spark.storage; -import static java.util.Collections.singletonList; - import java.util.Collection; +import java.util.List; import lombok.RequiredArgsConstructor; import org.opensearch.sql.DataSourceSchemaName; import org.opensearch.sql.expression.function.FunctionResolver; @@ -23,7 +22,7 @@ public class SparkStorageEngine implements StorageEngine { @Override public Collection getFunctions() { - return singletonList(new SparkSqlTableFunctionResolver(sparkClient)); + return List.of(new SparkSqlTableFunctionResolver(sparkClient)); } @Override diff --git a/sql/src/main/java/org/opensearch/sql/sql/parser/AstBuilder.java b/sql/src/main/java/org/opensearch/sql/sql/parser/AstBuilder.java index 8b4f331d77..fe6b9842a7 100644 --- a/sql/src/main/java/org/opensearch/sql/sql/parser/AstBuilder.java +++ b/sql/src/main/java/org/opensearch/sql/sql/parser/AstBuilder.java @@ -6,7 +6,6 @@ package org.opensearch.sql.sql.parser; import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; import static org.opensearch.sql.ast.dsl.AstDSL.qualifiedName; import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.FromClauseContext; import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.HavingClauseContext; @@ -20,6 +19,7 @@ import static org.opensearch.sql.utils.SystemIndexUtils.mappingTable; import com.google.common.collect.ImmutableList; +import java.util.List; import java.util.Optional; import lombok.RequiredArgsConstructor; import org.antlr.v4.runtime.tree.ParseTree; @@ -60,7 +60,7 @@ public class AstBuilder extends OpenSearchSQLParserBaseVisitor { @Override public UnresolvedPlan visitShowStatement(OpenSearchSQLParser.ShowStatementContext ctx) { final UnresolvedExpression tableFilter = visitAstExpression(ctx.tableFilter()); - return new Project(singletonList(AllFields.of())) + return new Project(List.of(AllFields.of())) .attach(new Filter(tableFilter).attach(new Relation(qualifiedName(TABLE_INFO)))); } @@ -70,9 +70,9 @@ public UnresolvedPlan visitDescribeStatement(OpenSearchSQLParser.DescribeStateme final String tableName = tableFilter.getFuncArgs().get(1).toString(); final Relation table = new Relation(qualifiedName(mappingTable(tableName.toString()))); if (ctx.columnFilter() == null) { - return new Project(singletonList(AllFields.of())).attach(table); + return new Project(List.of(AllFields.of())).attach(table); } else { - return new Project(singletonList(AllFields.of())) + return new Project(List.of(AllFields.of())) .attach(new Filter(visitAstExpression(ctx.columnFilter())).attach(table)); } } diff --git a/sql/src/main/java/org/opensearch/sql/sql/parser/AstExpressionBuilder.java b/sql/src/main/java/org/opensearch/sql/sql/parser/AstExpressionBuilder.java index eb76875f16..5e7687e409 100644 --- a/sql/src/main/java/org/opensearch/sql/sql/parser/AstExpressionBuilder.java +++ b/sql/src/main/java/org/opensearch/sql/sql/parser/AstExpressionBuilder.java @@ -5,7 +5,6 @@ package org.opensearch.sql.sql.parser; -import static java.util.Collections.singletonList; import static org.opensearch.sql.ast.dsl.AstDSL.between; import static org.opensearch.sql.ast.dsl.AstDSL.not; import static org.opensearch.sql.ast.dsl.AstDSL.qualifiedName; @@ -109,7 +108,7 @@ public UnresolvedExpression visitColumnName(ColumnNameContext ctx) { @Override public UnresolvedExpression visitIdent(IdentContext ctx) { - return visitIdentifiers(singletonList(ctx)); + return visitIdentifiers(List.of(ctx)); } @Override @@ -253,7 +252,7 @@ public UnresolvedExpression visitIsNullPredicate(IsNullPredicateContext ctx) { ctx.nullNotnull().NOT() == null ? IS_NULL.getName().getFunctionName() : IS_NOT_NULL.getName().getFunctionName(), - singletonList(visit(ctx.predicate()))); + List.of(visit(ctx.predicate()))); } @Override