diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 1bc25b6b034..3b48e25cfe4 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -5,7 +5,7 @@ This document contains a list of maintainers in this repo. See [opensearch-proje ## Current Maintainers | Maintainer | GitHub ID | Affiliation | -| ----------------- | ------------------------------------------------- | ----------- | +| ----------------- |-----------------------------------------------------| ----------- | | Eric Wei | [mengweieric](https://github.com/mengweieric) | Amazon | | Joshua Li | [joshuali925](https://github.com/joshuali925) | Amazon | | Shenoy Pratik | [ps48](https://github.com/ps48) | Amazon | @@ -16,7 +16,7 @@ This document contains a list of maintainers in this repo. See [opensearch-proje | Peter Fitzgibbons | [pjfitzgibbons](https://github.com/pjfitzgibbons) | Amazon | | Simeon Widdis | [swiddis](https://github.com/swiddis) | Amazon | | Chen Dai | [dai-chen](https://github.com/dai-chen) | Amazon | -| Vamsi Manohar | [vamsi-amazon](https://github.com/vamsi-amazon) | Amazon | +| Vamsi Manohar | [vamsi-amazon](https://github.com/vmmusings) | Amazon | | Peng Huo | [penghuo](https://github.com/penghuo) | Amazon | | Sean Kao | [seankao-az](https://github.com/seankao-az) | Amazon | | Anirudha Jadhav | [anirudha](https://github.com/anirudha) | Amazon | 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 52c829318ab..eb83afdf7b2 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 @@ -10,7 +10,6 @@ import com.google.common.annotations.VisibleForTesting; import java.time.Clock; import java.time.Duration; -import java.util.Arrays; import java.util.List; import org.opensearch.client.Client; import org.opensearch.cluster.LocalNodeClusterManagerListener; @@ -183,7 +182,7 @@ private void cancel(Cancellable cron) { @VisibleForTesting public List getFlintIndexRetentionCron() { - return Arrays.asList(flintIndexRetentionCron); + return List.of(flintIndexRetentionCron); } private String executorName() { diff --git a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java index 9511359f86a..84b3c33fd62 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java @@ -21,7 +21,6 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; import java.net.URL; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -137,7 +136,7 @@ public class AsyncQueryExecutorServiceSpec extends OpenSearchIntegTestCase { @Override protected Collection> nodePlugins() { - return Arrays.asList(TestSettingPlugin.class); + return List.of(TestSettingPlugin.class); } public static class TestSettingPlugin extends Plugin { diff --git a/core/src/main/java/org/opensearch/sql/analysis/NestedAnalyzer.java b/core/src/main/java/org/opensearch/sql/analysis/NestedAnalyzer.java index ef8f1428018..84c2bd427a1 100644 --- a/core/src/main/java/org/opensearch/sql/analysis/NestedAnalyzer.java +++ b/core/src/main/java/org/opensearch/sql/analysis/NestedAnalyzer.java @@ -8,7 +8,6 @@ import static org.opensearch.sql.data.type.ExprCoreType.STRING; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import lombok.RequiredArgsConstructor; @@ -94,7 +93,7 @@ public LogicalPlan visitFunction(Function node, AnalysisContext context) { generatePath(nestedField.toString())); } - return mergeChildIfLogicalNested(new ArrayList<>(Arrays.asList(args))); + return mergeChildIfLogicalNested(new ArrayList<>(List.of(args))); } return null; } 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 4c2a485ea77..b4e860811f9 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,7 +5,6 @@ package org.opensearch.sql.ast.expression; -import java.util.Arrays; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -25,7 +24,7 @@ public class Argument extends UnresolvedExpression { // private final DataType valueType; @Override public List getChild() { - return Arrays.asList(value); + return List.of(value); } @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 38c1b91b43c..00f4150242b 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,7 +5,6 @@ package org.opensearch.sql.ast.expression; -import java.util.Arrays; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -28,7 +27,7 @@ public class In extends UnresolvedExpression { @Override public List getChild() { - return Arrays.asList(field); + return List.of(field); } @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 423cb088efe..1794c75080e 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,7 +5,6 @@ package org.opensearch.sql.ast.expression; -import java.util.Arrays; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -23,7 +22,7 @@ public class Not extends UnresolvedExpression { @Override public List getChild() { - return Arrays.asList(expression); + return List.of(expression); } @Override 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 2c6eee46e9c..cd826e8d90f 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,7 +5,6 @@ package org.opensearch.sql.ast.expression; -import java.util.Arrays; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -27,7 +26,7 @@ public UnresolvedArgument(String argName, UnresolvedExpression value) { @Override public List getChild() { - return Arrays.asList(value); + return List.of(value); } @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 ec5264a86b7..0256ae41242 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 @@ -6,7 +6,6 @@ package org.opensearch.sql.ast.tree; import com.google.common.collect.ImmutableList; -import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import lombok.AllArgsConstructor; @@ -32,7 +31,7 @@ public Relation(UnresolvedExpression tableName) { } public Relation(UnresolvedExpression tableName, String alias) { - this.tableName = Arrays.asList(tableName); + this.tableName = List.of(tableName); this.alias = alias; } diff --git a/core/src/main/java/org/opensearch/sql/data/type/ExprType.java b/core/src/main/java/org/opensearch/sql/data/type/ExprType.java index 58d6ee346ba..2732854a14e 100644 --- a/core/src/main/java/org/opensearch/sql/data/type/ExprType.java +++ b/core/src/main/java/org/opensearch/sql/data/type/ExprType.java @@ -7,7 +7,6 @@ import static org.opensearch.sql.data.type.ExprCoreType.UNKNOWN; -import java.util.Arrays; import java.util.List; import org.opensearch.sql.data.model.ExprValue; import org.opensearch.sql.expression.Expression; @@ -44,7 +43,7 @@ default boolean shouldCast(ExprType other) { /** Get the parent type. */ default List getParent() { - return Arrays.asList(UNKNOWN); + return List.of(UNKNOWN); } /** Get the type name. */ 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 92734440f75..33fbdfd00e1 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,7 +5,6 @@ package org.opensearch.sql.planner.logical; -import java.util.Arrays; import java.util.List; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -30,7 +29,7 @@ public LogicalDedupe( Integer allowedDuplication, Boolean keepEmpty, Boolean consecutive) { - super(Arrays.asList(child)); + super(List.of(child)); this.dedupeList = dedupeList; this.allowedDuplication = allowedDuplication; this.keepEmpty = keepEmpty; 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 38d4704bcd2..590f18f96f6 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/SelectExpressionAnalyzerTest.java +++ b/core/src/test/java/org/opensearch/sql/analysis/SelectExpressionAnalyzerTest.java @@ -11,7 +11,6 @@ import static org.opensearch.sql.data.type.ExprCoreType.INTEGER; import static org.opensearch.sql.data.type.ExprCoreType.STRUCT; -import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -77,11 +76,11 @@ protected List analyze(UnresolvedExpression unresolvedExpressio .when(optimizer) .optimize(any(), any()); return new SelectExpressionAnalyzer(expressionAnalyzer) - .analyze(Arrays.asList(unresolvedExpression), analysisContext, optimizer); + .analyze(List.of(unresolvedExpression), analysisContext, optimizer); } protected void assertAnalyzeEqual( NamedExpression expected, UnresolvedExpression unresolvedExpression) { - assertEquals(Arrays.asList(expected), analyze(unresolvedExpression)); + assertEquals(List.of(expected), analyze(unresolvedExpression)); } } diff --git a/core/src/test/java/org/opensearch/sql/analysis/model/DataSourceSchemaIdentifierNameResolverTest.java b/core/src/test/java/org/opensearch/sql/analysis/model/DataSourceSchemaIdentifierNameResolverTest.java index 775984a528a..ae82a7d2056 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/model/DataSourceSchemaIdentifierNameResolverTest.java +++ b/core/src/test/java/org/opensearch/sql/analysis/model/DataSourceSchemaIdentifierNameResolverTest.java @@ -40,7 +40,7 @@ void testFullyQualifiedName() { @Test void defaultDataSourceNameResolve() { when(dataSourceService.dataSourceExists(any())).thenReturn(Boolean.FALSE); - identifierOf(Arrays.asList("tables"), dataSourceService) + identifierOf(List.of("tables"), dataSourceService) .datasource(DEFAULT_DATASOURCE_NAME) .schema(DEFAULT_SCHEMA_NAME) .name("tables"); diff --git a/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java b/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java index 9fe63471028..3d304ffb114 100644 --- a/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java +++ b/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java @@ -126,7 +126,7 @@ private static Stream getValueTestArgumentStream() { 1D, "1", true, - Arrays.asList(integerValue(1)), + List.of(integerValue(1)), ImmutableMap.of("1", integerValue(1)), LocalDate.parse("2012-08-07"), LocalTime.parse("18:00:00"), 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 237477050dc..ae345fa9890 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 @@ -24,7 +24,6 @@ import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_BOOLEAN; import com.google.common.collect.ImmutableList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -73,7 +72,7 @@ void register() { @Test void compile() { when(mockExpression.type()).thenReturn(UNDEFINED); - when(functionSignature.getParamTypeList()).thenReturn(Arrays.asList(UNDEFINED)); + when(functionSignature.getParamTypeList()).thenReturn(List.of(UNDEFINED)); when(mockfunctionResolver.getFunctionName()).thenReturn(mockFunctionName); when(mockfunctionResolver.resolve(any())) .thenReturn(Pair.of(functionSignature, functionExpressionBuilder)); @@ -82,7 +81,7 @@ void compile() { BuiltinFunctionRepository repo = new BuiltinFunctionRepository(mockMap); repo.register(mockfunctionResolver); - repo.compile(functionProperties, mockFunctionName, Arrays.asList(mockExpression)); + repo.compile(functionProperties, mockFunctionName, List.of(mockExpression)); verify(functionExpressionBuilder, times(1)).apply(eq(functionProperties), any()); } @@ -90,7 +89,7 @@ void compile() { void compile_datasource_defined_function() { DefaultFunctionResolver dataSourceFunctionResolver = mock(DefaultFunctionResolver.class); when(mockExpression.type()).thenReturn(UNDEFINED); - when(functionSignature.getParamTypeList()).thenReturn(Arrays.asList(UNDEFINED)); + when(functionSignature.getParamTypeList()).thenReturn(List.of(UNDEFINED)); when(dataSourceFunctionResolver.getFunctionName()).thenReturn(mockFunctionName); when(dataSourceFunctionResolver.resolve(any())) .thenReturn(Pair.of(functionSignature, functionExpressionBuilder)); @@ -100,7 +99,7 @@ void compile_datasource_defined_function() { functionProperties, Collections.singletonList(dataSourceFunctionResolver), mockFunctionName, - Arrays.asList(mockExpression)); + 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 8e71fc2bec8..7aad75b2043 100644 --- a/core/src/test/java/org/opensearch/sql/planner/DefaultImplementorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/DefaultImplementorTest.java @@ -31,7 +31,6 @@ import static org.opensearch.sql.planner.logical.LogicalPlanDSL.window; import com.google.common.collect.ImmutableMap; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -92,12 +91,12 @@ public void visit_should_return_default_physical_operator() { ReferenceExpression exclude = ref("name", STRING); ReferenceExpression dedupeField = ref("name", STRING); Expression filterExpr = literal(ExprBooleanValue.of(true)); - List groupByExprs = Arrays.asList(DSL.named("age", ref("age", INTEGER))); - List aggExprs = Arrays.asList(ref("age", INTEGER)); + List groupByExprs = List.of(DSL.named("age", ref("age", INTEGER))); + List aggExprs = List.of(ref("age", INTEGER)); ReferenceExpression rareTopNField = ref("age", INTEGER); - List topByExprs = Arrays.asList(ref("age", INTEGER)); + List topByExprs = List.of(ref("age", INTEGER)); List aggregators = - Arrays.asList(DSL.named("avg(age)", new AvgAggregator(aggExprs, ExprCoreType.DOUBLE))); + List.of(DSL.named("avg(age)", new AvgAggregator(aggExprs, ExprCoreType.DOUBLE))); Map mappings = ImmutableMap.of(ref("name", STRING), ref("lastname", STRING)); Pair newEvalField = diff --git a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/ComparisonTestTest.java b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/ComparisonTestTest.java index 5cab5b31752..793d9aa03bc 100644 --- a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/ComparisonTestTest.java +++ b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/ComparisonTestTest.java @@ -12,6 +12,7 @@ import static org.mockito.Mockito.when; import java.util.Collections; +import java.util.List; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -51,14 +52,14 @@ public void testSuccess() { .thenReturn( new DBResult( "OpenSearch", - asList(new Type("firstname", "text")), - asList(new Row(asList("John"))))); + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John"))))); when(otherDbConnection.select(anyString())) .thenReturn( new DBResult( "Other DB", - asList(new Type("firstname", "text")), - asList(new Row(asList("John"))))); + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John"))))); TestReport expected = new TestReport(); expected.addTestCase(new SuccessTestCase(1, "SELECT * FROM accounts")); @@ -70,10 +71,12 @@ public void testSuccess() { public void testFailureDueToInconsistency() { DBResult openSearchResult = new DBResult( - "OpenSearch", asList(new Type("firstname", "text")), asList(new Row(asList("John")))); + "OpenSearch", + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John")))); DBResult otherDbResult = new DBResult( - "Other DB", asList(new Type("firstname", "text")), asList(new Row(asList("JOHN")))); + "Other DB", List.of(new Type("firstname", "text")), List.of(new Row(List.of("JOHN")))); when(openSearchConnection.select(anyString())).thenReturn(openSearchResult); when(otherDbConnection.select(anyString())).thenReturn(otherDbResult); @@ -95,13 +98,17 @@ public void testSuccessFinally() { DBResult openSearchResult = new DBResult( - "OpenSearch", asList(new Type("firstname", "text")), asList(new Row(asList("John")))); + "OpenSearch", + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John")))); DBResult otherDbResult = new DBResult( - "Other DB", asList(new Type("firstname", "text")), asList(new Row(asList("JOHN")))); + "Other DB", List.of(new Type("firstname", "text")), List.of(new Row(List.of("JOHN")))); DBResult anotherDbResult = new DBResult( - "Another DB", asList(new Type("firstname", "text")), asList(new Row(asList("John")))); + "Another DB", + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John")))); when(openSearchConnection.select(anyString())).thenReturn(openSearchResult); when(anotherDbConnection.select(anyString())).thenReturn(anotherDbResult); @@ -122,13 +129,15 @@ public void testFailureDueToEventualInconsistency() { DBResult openSearchResult = new DBResult( - "OpenSearch", asList(new Type("firstname", "text")), asList(new Row(asList("John")))); + "OpenSearch", + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John")))); DBResult otherDbResult = new DBResult( - "Other DB", asList(new Type("firstname", "text")), asList(new Row(asList("JOHN")))); + "Other DB", List.of(new Type("firstname", "text")), List.of(new Row(List.of("JOHN")))); DBResult anotherDbResult = new DBResult( - "ZZZ DB", asList(new Type("firstname", "text")), asList(new Row(asList("Hank")))); + "ZZZ DB", List.of(new Type("firstname", "text")), List.of(new Row(List.of("Hank")))); when(openSearchConnection.select(anyString())).thenReturn(openSearchResult); when(otherDbConnection.select(anyString())).thenReturn(otherDbResult); when(anotherDbConnection.select(anyString())).thenReturn(anotherDbResult); @@ -162,8 +171,8 @@ public void testErrorDueToNoOtherDBSupportThisQuery() { .thenReturn( new DBResult( "OpenSearch", - asList(new Type("firstname", "text")), - asList(new Row(asList("John"))))); + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John"))))); when(otherDbConnection.select(anyString())) .thenThrow(new RuntimeException("Unsupported feature")); @@ -189,14 +198,14 @@ public void testSuccessWhenOneDBSupportThisQuery() { .thenReturn( new DBResult( "OpenSearch", - asList(new Type("firstname", "text")), - asList(new Row(asList("John"))))); + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John"))))); when(anotherDbConnection.select(anyString())) .thenReturn( new DBResult( "Another DB", - asList(new Type("firstname", "text")), - asList(new Row(asList("John"))))); + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John"))))); TestReport expected = new TestReport(); expected.addTestCase(new SuccessTestCase(1, "SELECT * FROM accounts")); @@ -214,9 +223,11 @@ public void testFailureDueToInconsistencyAndExceptionMixed() { DBResult openSearchResult = new DBResult( - "OpenSearch", asList(new Type("firstname", "text")), asList(new Row(asList("John")))); + "OpenSearch", + List.of(new Type("firstname", "text")), + List.of(new Row(List.of("John")))); DBResult otherResult = - new DBResult("Other", asList(new Type("firstname", "text")), Collections.emptyList()); + new DBResult("Other", List.of(new Type("firstname", "text")), Collections.emptyList()); when(openSearchConnection.select(anyString())).thenReturn(openSearchResult); when(otherDbConnection.select(anyString())).thenReturn(otherResult); diff --git a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/DBResultTest.java b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/DBResultTest.java index 793728a9e90..bbbfe6cb2ae 100644 --- a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/DBResultTest.java +++ b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/DBResultTest.java @@ -12,7 +12,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import java.util.Arrays; +import java.util.List; import org.junit.Test; import org.opensearch.sql.correctness.runner.resultset.DBResult; import org.opensearch.sql.correctness.runner.resultset.Row; @@ -23,18 +23,15 @@ public class DBResultTest { @Test public void dbResultFromDifferentDbNameShouldEqual() { - DBResult result1 = - new DBResult("DB 1", Arrays.asList(new Type("name", "VARCHAR")), emptyList()); - DBResult result2 = - new DBResult("DB 2", Arrays.asList(new Type("name", "VARCHAR")), emptyList()); + DBResult result1 = new DBResult("DB 1", List.of(new Type("name", "VARCHAR")), emptyList()); + DBResult result2 = new DBResult("DB 2", List.of(new Type("name", "VARCHAR")), emptyList()); assertEquals(result1, result2); } @Test public void dbResultWithDifferentColumnShouldNotEqual() { - DBResult result1 = - new DBResult("DB 1", Arrays.asList(new Type("name", "VARCHAR")), emptyList()); - DBResult result2 = new DBResult("DB 2", Arrays.asList(new Type("age", "INT")), emptyList()); + DBResult result1 = new DBResult("DB 1", List.of(new Type("name", "VARCHAR")), emptyList()); + DBResult result2 = new DBResult("DB 2", List.of(new Type("age", "INT")), emptyList()); assertNotEquals(result1, result2); } @@ -70,8 +67,8 @@ public void dbResultInOrderWithSameRowsInDifferentOrderShouldNotEqual() { @Test public void dbResultWithDifferentColumnTypeShouldNotEqual() { - DBResult result1 = new DBResult("DB 1", Arrays.asList(new Type("age", "FLOAT")), emptyList()); - DBResult result2 = new DBResult("DB 2", Arrays.asList(new Type("age", "INT")), emptyList()); + DBResult result1 = new DBResult("DB 1", List.of(new Type("age", "FLOAT")), emptyList()); + DBResult result2 = new DBResult("DB 2", List.of(new Type("age", "INT")), emptyList()); assertNotEquals(result1, result2); } @@ -79,14 +76,10 @@ public void dbResultWithDifferentColumnTypeShouldNotEqual() { public void shouldExplainColumnTypeDifference() { DBResult result1 = new DBResult( - "DB 1", - Arrays.asList(new Type("name", "VARCHAR"), new Type("age", "FLOAT")), - emptyList()); + "DB 1", List.of(new Type("name", "VARCHAR"), new Type("age", "FLOAT")), emptyList()); DBResult result2 = new DBResult( - "DB 2", - Arrays.asList(new Type("name", "VARCHAR"), new Type("age", "INT")), - emptyList()); + "DB 2", List.of(new Type("name", "VARCHAR"), new Type("age", "INT")), emptyList()); assertEquals( "Schema type at [1] is different: " @@ -99,19 +92,19 @@ public void shouldExplainDataRowsDifference() { DBResult result1 = new DBResult( "DB 1", - Arrays.asList(new Type("name", "VARCHAR")), + List.of(new Type("name", "VARCHAR")), Sets.newHashSet( - new Row(Arrays.asList("hello")), - new Row(Arrays.asList("world")), + new Row(List.of("hello")), + new Row(List.of("world")), new Row(Lists.newArrayList((Object) null)))); DBResult result2 = new DBResult( "DB 2", - Arrays.asList(new Type("name", "VARCHAR")), + List.of(new Type("name", "VARCHAR")), Sets.newHashSet( new Row(Lists.newArrayList((Object) null)), - new Row(Arrays.asList("hello")), - new Row(Arrays.asList("world123")))); + new Row(List.of("hello")), + new Row(List.of("world123")))); assertEquals( "Data row at [1] is different: this=[Row(values=[world])], other=[Row(values=[world123])]", diff --git a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java index 43f678f60ed..435c9f0e1ec 100644 --- a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java +++ b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java @@ -60,11 +60,11 @@ public void testFailedReport() { new DBResult( "OpenSearch", singleton(new Type("firstName", "text")), - singleton(new Row(asList("hello")))), + singleton(new Row(singleton("hello")))), new DBResult( "H2", singleton(new Type("firstName", "text")), - singleton(new Row(asList("world"))))), + singleton(new Row(singleton("world"))))), "[SQLITE_ERROR] SQL error or missing database;")); JSONObject actual = new JSONObject(report); JSONObject expected = 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 07883d92f4c..a0729e94ce1 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 @@ -13,7 +13,6 @@ import com.google.common.collect.Sets; import java.io.IOException; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -71,7 +70,7 @@ public class PrettyFormatResponseIT extends SQLIntegTestCase { private static final Set commentFields = Sets.newHashSet("comment.data", "comment.likes"); - private static final List nameFields = Arrays.asList("firstname", "lastname"); + private static final List nameFields = List.of("firstname", "lastname"); private final int RESPONSE_DEFAULT_MAX_SIZE = 200; @@ -222,7 +221,7 @@ public void selectNestedFields() throws IOException { "SELECT nested(message.info), someField FROM %s", TestsConstants.TEST_INDEX_NESTED_TYPE)); - List fields = Arrays.asList("nested(message.info)", "someField"); + List fields = List.of("nested(message.info)", "someField"); assertContainsColumns(getSchema(response), fields); assertContainsData(getDataRows(response), fields); @@ -291,7 +290,7 @@ public void groupByMultipleFields() throws IOException { "SELECT * FROM %s GROUP BY age, balance", TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = Arrays.asList("age", "balance"); + List fields = List.of("age", "balance"); assertContainsColumns(getSchema(response), fields); assertContainsData(getDataRows(response), fields); } @@ -335,7 +334,7 @@ public void aggregationFunctionInSelect() throws IOException { "SELECT COUNT(*) FROM %s GROUP BY age", TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = Arrays.asList("COUNT(*)"); + List fields = List.of("COUNT(*)"); assertContainsColumns(getSchema(response), fields); JSONArray dataRows = getDataRows(response); @@ -357,7 +356,7 @@ public void aggregationFunctionInSelectCaseCheck() throws IOException { "SELECT count(*) FROM %s GROUP BY age", TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = Arrays.asList("COUNT(*)"); + List fields = List.of("COUNT(*)"); assertContainsColumns(getSchema(response), fields); JSONArray dataRows = getDataRows(response); @@ -378,7 +377,7 @@ public void aggregationFunctionInSelectWithAlias() throws IOException { "SELECT COUNT(*) AS total FROM %s GROUP BY age", TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = Arrays.asList("total"); + List fields = List.of("total"); assertContainsColumns(getSchema(response), fields); JSONArray dataRows = getDataRows(response); @@ -418,7 +417,7 @@ public void multipleAggregationFunctionsInSelect() throws IOException { "SELECT COUNT(*), AVG(age) FROM %s GROUP BY age", TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = Arrays.asList("COUNT(*)", "AVG(age)"); + List fields = List.of("COUNT(*)", "AVG(age)"); assertContainsColumns(getSchema(response), fields); assertContainsData(getDataRows(response), fields); } @@ -496,7 +495,7 @@ public void joinQuery() throws IOException { TestsConstants.TEST_INDEX_ACCOUNT, TestsConstants.TEST_INDEX_ACCOUNT)); - List fields = Arrays.asList("b1.balance", "b1.age", "b2.firstname"); + List fields = List.of("b1.balance", "b1.age", "b2.firstname"); assertContainsColumns(getSchema(response), fields); assertContainsData(getDataRows(response), fields); } @@ -518,7 +517,7 @@ public void joinQueryWithAlias() throws IOException { aliases.put("b2.firstname", "name"); assertContainsAliases(getSchema(response), aliases); - assertContainsData(getDataRows(response), Arrays.asList("bal", "age", "name")); + assertContainsData(getDataRows(response), List.of("bal", "age", "name")); } @Test @@ -532,7 +531,7 @@ public void joinQueryWithObjectFieldInSelect() throws IOException { TestsConstants.TEST_INDEX_GAME_OF_THRONES, TestsConstants.TEST_INDEX_GAME_OF_THRONES)); - List fields = Arrays.asList("c.name.firstname", "d.name.lastname"); + List fields = List.of("c.name.firstname", "d.name.lastname"); assertContainsColumns(getSchema(response), fields); // d.name.lastname is null here since entries with hname don't have a name.lastname entry, so diff --git a/integ-test/src/test/java/org/opensearch/sql/util/MatcherUtils.java b/integ-test/src/test/java/org/opensearch/sql/util/MatcherUtils.java index d4db502407a..ffbc1ed7a7c 100644 --- a/integ-test/src/test/java/org/opensearch/sql/util/MatcherUtils.java +++ b/integ-test/src/test/java/org/opensearch/sql/util/MatcherUtils.java @@ -296,7 +296,7 @@ protected boolean matchesSafely(JSONArray item) { @Override public void describeTo(Description description) { - description.appendText(String.join(",", Arrays.asList().toString())); + description.appendText(String.join(",", List.of().toString())); } private boolean valuesAreClose(Number v1, Number v2) { 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 3d40c3a527f..d7682d7bf34 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,7 +5,6 @@ package org.opensearch.sql.legacy.expression.core.builder; -import java.util.Arrays; import java.util.List; import lombok.RequiredArgsConstructor; import org.opensearch.sql.legacy.expression.core.Expression; @@ -31,7 +30,7 @@ public Expression build(List expressionList) { return new Expression() { @Override public ExprValue valueOf(BindingTuple tuple) { - return op.apply(Arrays.asList(expression.valueOf(tuple))); + return op.apply(List.of(expression.valueOf(tuple))); } @Override diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/TypeExpressionTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/TypeExpressionTest.java index 55c184bcaaf..41b6cb57907 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/TypeExpressionTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/types/TypeExpressionTest.java @@ -18,6 +18,7 @@ import static org.opensearch.sql.legacy.antlr.semantic.types.special.Generic.T; import java.util.Arrays; +import java.util.List; import org.junit.Test; /** Test cases for default implementation methods in interface TypeExpression */ @@ -54,20 +55,20 @@ public String getName() { return "Temp type expression with empty specification"; } }; - assertEquals(UNKNOWN, expr.construct(Arrays.asList(NUMBER))); + assertEquals(UNKNOWN, expr.construct(List.of(NUMBER))); assertEquals(UNKNOWN, expr.construct(Arrays.asList(STRING, BOOLEAN))); assertEquals(UNKNOWN, expr.construct(Arrays.asList(INTEGER, DOUBLE, GEO_POINT))); } @Test public void compatibilityCheckShouldPassIfAnySpecificationCompatible() { - assertEquals(DOUBLE, test123.construct(Arrays.asList(DOUBLE))); + assertEquals(DOUBLE, test123.construct(List.of(DOUBLE))); assertEquals(DATE, test123.construct(Arrays.asList(STRING, BOOLEAN))); } @Test public void compatibilityCheckShouldFailIfNoSpecificationCompatible() { - assertEquals(TYPE_ERROR, test123.construct(Arrays.asList(BOOLEAN))); + assertEquals(TYPE_ERROR, test123.construct(List.of(BOOLEAN))); } @Test 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 fa385fa14b1..8216a5fdbb6 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 @@ -13,7 +13,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import java.util.Arrays; import java.util.List; import java.util.Map; import org.hamcrest.Matcher; @@ -30,10 +29,10 @@ public class BindingTupleResultSetTest { public void buildDataRowsFromBindingTupleShouldPass() { assertThat( row( - Arrays.asList( + List.of( ColumnNode.builder().name("age").type(Schema.Type.INTEGER).build(), ColumnNode.builder().name("gender").type(Schema.Type.TEXT).build()), - Arrays.asList( + List.of( BindingTuple.from(ImmutableMap.of("age", 31, "gender", "m")), BindingTuple.from(ImmutableMap.of("age", 31, "gender", "f")), BindingTuple.from(ImmutableMap.of("age", 39, "gender", "m")), @@ -49,10 +48,10 @@ public void buildDataRowsFromBindingTupleShouldPass() { public void buildDataRowsFromBindingTupleIncludeLongValueShouldPass() { assertThat( row( - Arrays.asList( + List.of( ColumnNode.builder().name("longValue").type(Schema.Type.LONG).build(), ColumnNode.builder().name("gender").type(Schema.Type.TEXT).build()), - Arrays.asList( + List.of( BindingTuple.from(ImmutableMap.of("longValue", Long.MAX_VALUE, "gender", "m")), BindingTuple.from(ImmutableMap.of("longValue", Long.MIN_VALUE, "gender", "f")))), containsInAnyOrder( @@ -66,10 +65,10 @@ public void buildDataRowsFromBindingTupleIncludeLongValueShouldPass() { public void buildDataRowsFromBindingTupleIncludeDateShouldPass() { assertThat( row( - Arrays.asList( + List.of( ColumnNode.builder().alias("dateValue").type(Schema.Type.DATE).build(), ColumnNode.builder().alias("gender").type(Schema.Type.TEXT).build()), - Arrays.asList( + List.of( BindingTuple.from(ImmutableMap.of("dateValue", 1529712000000L, "gender", "m")))), containsInAnyOrder( rowContents( diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java index 983f10023ee..2f3e34d43aa 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java @@ -16,7 +16,6 @@ import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr; import com.google.common.collect.ImmutableList; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.junit.Assert; import org.junit.Rule; @@ -92,6 +91,6 @@ public void testCastIntStatementScript() throws SqlParseException { "def result = (doc['age'].value instanceof boolean) " + "? (doc['age'].value ? 1 : 0) " + ": Double.parseDouble(doc['age'].value.toString()).intValue()", - sqlFunctions.getCastScriptStatement("result", "int", Arrays.asList(new KVValue("age")))); + sqlFunctions.getCastScriptStatement("result", "int", List.of(new KVValue("age")))); } } diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/request/system/OpenSearchCatIndicesRequestTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/request/system/OpenSearchCatIndicesRequestTest.java index 8f954b68b2a..83bfbd5cd65 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/request/system/OpenSearchCatIndicesRequestTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/request/system/OpenSearchCatIndicesRequestTest.java @@ -12,7 +12,6 @@ import static org.mockito.Mockito.when; import static org.opensearch.sql.data.model.ExprValueUtils.stringValue; -import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -28,7 +27,7 @@ class OpenSearchCatIndicesRequestTest { @Test void testSearch() { - when(client.indices()).thenReturn(Arrays.asList("index")); + when(client.indices()).thenReturn(List.of("index")); final List results = new OpenSearchCatIndicesRequest(client).search(); assertEquals(1, results.size()); 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 1bb988dacd7..cb55fd3cfb2 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 @@ -30,7 +30,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.AbstractMap; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -97,9 +96,8 @@ void should_build_composite_aggregation_for_field_reference() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))), - Arrays.asList(named("name", ref("name", STRING))))); + List.of(named("avg(age)", new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER))), + List.of(named("name", ref("name", STRING))))); } @Test @@ -131,9 +129,8 @@ void should_build_composite_aggregation_for_field_reference_with_order() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))), - Arrays.asList(named("name", ref("name", STRING))), + List.of(named("avg(age)", new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER))), + List.of(named("name", ref("name", STRING))), sort(ref("name", STRING), Sort.SortOption.DEFAULT_DESC))); } @@ -141,9 +138,8 @@ void should_build_composite_aggregation_for_field_reference_with_order() { void should_build_type_mapping_for_field_reference() { assertThat( buildTypeMapping( - Arrays.asList( - named("avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))), - Arrays.asList(named("name", ref("name", STRING)))), + List.of(named("avg(age)", new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER))), + List.of(named("name", ref("name", STRING)))), containsInAnyOrder( map("avg(age)", OpenSearchDataType.of(INTEGER)), map("name", OpenSearchDataType.of(STRING)))); @@ -153,11 +149,11 @@ void should_build_type_mapping_for_field_reference() { void should_build_type_mapping_for_timestamp_type() { assertThat( buildTypeMapping( - Arrays.asList( + List.of( named( "avg(timestamp)", - new AvgAggregator(Arrays.asList(ref("timestamp", TIMESTAMP)), TIMESTAMP))), - Arrays.asList(named("timestamp", ref("timestamp", TIMESTAMP)))), + new AvgAggregator(List.of(ref("timestamp", TIMESTAMP)), TIMESTAMP))), + List.of(named("timestamp", ref("timestamp", TIMESTAMP)))), containsInAnyOrder( map("avg(timestamp)", OpenSearchDateType.of()), map("timestamp", OpenSearchDateType.of()))); @@ -167,9 +163,8 @@ void should_build_type_mapping_for_timestamp_type() { void should_build_type_mapping_for_date_type() { assertThat( buildTypeMapping( - Arrays.asList( - named("avg(date)", new AvgAggregator(Arrays.asList(ref("date", DATE)), DATE))), - Arrays.asList(named("date", ref("date", DATE)))), + List.of(named("avg(date)", new AvgAggregator(List.of(ref("date", DATE)), DATE))), + List.of(named("date", ref("date", DATE)))), containsInAnyOrder( map("avg(date)", OpenSearchDateType.of(DATE)), map("date", OpenSearchDateType.of(DATE)))); @@ -179,9 +174,8 @@ void should_build_type_mapping_for_date_type() { void should_build_type_mapping_for_time_type() { assertThat( buildTypeMapping( - Arrays.asList( - named("avg(time)", new AvgAggregator(Arrays.asList(ref("time", TIME)), TIME))), - Arrays.asList(named("time", ref("time", TIME)))), + List.of(named("avg(time)", new AvgAggregator(List.of(ref("time", TIME)), TIME))), + List.of(named("time", ref("time", TIME)))), containsInAnyOrder( map("avg(time)", OpenSearchDateType.of(TIME)), map("time", OpenSearchDateType.of(TIME)))); @@ -216,9 +210,8 @@ void should_build_composite_aggregation_for_field_reference_of_keyword() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))), - Arrays.asList( + List.of(named("avg(age)", new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER))), + List.of( named( "name", ref( @@ -234,9 +227,8 @@ void should_build_composite_aggregation_for_field_reference_of_keyword() { void should_build_type_mapping_for_field_reference_of_keyword() { assertThat( buildTypeMapping( - Arrays.asList( - named("avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))), - Arrays.asList(named("name", ref("name", STRING)))), + List.of(named("avg(age)", new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER))), + List.of(named("name", ref("name", STRING)))), containsInAnyOrder( map("avg(age)", OpenSearchDataType.of(INTEGER)), map("name", OpenSearchDataType.of(STRING)))); @@ -284,11 +276,11 @@ void should_build_composite_aggregation_for_expression() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( "avg(balance)", - new AvgAggregator(Arrays.asList(DSL.abs(ref("balance", INTEGER))), INTEGER))), - Arrays.asList(named("age", DSL.asin(ref("age", INTEGER)))))); + new AvgAggregator(List.of(DSL.abs(ref("balance", INTEGER))), INTEGER))), + List.of(named("age", DSL.asin(ref("age", INTEGER)))))); } @Test @@ -342,11 +334,11 @@ void should_build_composite_aggregation_follow_with_order_by_position() { void should_build_type_mapping_for_expression() { assertThat( buildTypeMapping( - Arrays.asList( + List.of( named( "avg(balance)", - new AvgAggregator(Arrays.asList(DSL.abs(ref("balance", INTEGER))), INTEGER))), - Arrays.asList(named("age", DSL.asin(ref("age", 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)), map("age", OpenSearchDataType.of(DOUBLE)))); @@ -364,11 +356,10 @@ void should_build_aggregation_without_bucket() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( - "avg(balance)", - new AvgAggregator(Arrays.asList(ref("balance", INTEGER)), INTEGER))), - Collections.emptyList())); + "avg(balance)", new AvgAggregator(List.of(ref("balance", INTEGER)), INTEGER))), + List.of())); } @Test @@ -398,12 +389,12 @@ void should_build_filter_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( "avg(age) filter(where age > 34)", - new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER) + new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER) .condition(DSL.greater(ref("age", INTEGER), literal(20))))), - Collections.emptyList())); + List.of())); } @Test @@ -450,23 +441,22 @@ void should_build_filter_aggregation_group_by() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( "avg(age) filter(where age > 34)", - new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER) + new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER) .condition(DSL.greater(ref("age", INTEGER), literal(20))))), - Arrays.asList(named(ref("gender", OpenSearchDataType.of(STRING)))))); + List.of(named(ref("gender", OpenSearchDataType.of(STRING)))))); } @Test void should_build_type_mapping_without_bucket() { assertThat( buildTypeMapping( - Arrays.asList( + List.of( named( - "avg(balance)", - new AvgAggregator(Arrays.asList(ref("balance", INTEGER)), INTEGER))), - Collections.emptyList()), + "avg(balance)", new AvgAggregator(List.of(ref("balance", INTEGER)), INTEGER))), + List.of()), containsInAnyOrder(map("avg(balance)", OpenSearchDataType.of(INTEGER)))); } @@ -500,9 +490,8 @@ void should_build_histogram() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("count(a)", new CountAggregator(Arrays.asList(ref("a", INTEGER)), INTEGER))), - Arrays.asList(named(span(ref("age", INTEGER), literal(10), ""))))); + List.of(named("count(a)", new CountAggregator(List.of(ref("a", INTEGER)), INTEGER))), + List.of(named(span(ref("age", INTEGER), literal(10), ""))))); } @Test @@ -541,9 +530,9 @@ void should_build_histogram_two_metrics() { + "}"), buildQuery( Arrays.asList( - named("count(a)", new CountAggregator(Arrays.asList(ref("a", INTEGER)), INTEGER)), - named("avg(b)", new AvgAggregator(Arrays.asList(ref("b", INTEGER)), INTEGER))), - Arrays.asList(named(span(ref("age", INTEGER), literal(10), ""))))); + named("count(a)", new CountAggregator(List.of(ref("a", INTEGER)), INTEGER)), + named("avg(b)", new AvgAggregator(List.of(ref("b", INTEGER)), INTEGER))), + List.of(named(span(ref("age", INTEGER), literal(10), ""))))); } @Test @@ -576,9 +565,8 @@ void fixed_interval_time_span() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("count(a)", new CountAggregator(Arrays.asList(ref("a", INTEGER)), INTEGER))), - Arrays.asList(named(span(ref("timestamp", TIMESTAMP), literal(1), "h"))))); + List.of(named("count(a)", new CountAggregator(List.of(ref("a", INTEGER)), INTEGER))), + List.of(named(span(ref("timestamp", TIMESTAMP), literal(1), "h"))))); } @Test @@ -611,9 +599,8 @@ void calendar_interval_time_span() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("count(a)", new CountAggregator(Arrays.asList(ref("a", INTEGER)), INTEGER))), - Arrays.asList(named(span(ref("date", DATE), literal(1), "w"))))); + List.of(named("count(a)", new CountAggregator(List.of(ref("a", INTEGER)), INTEGER))), + List.of(named(span(ref("date", DATE), literal(1), "w"))))); } @Test @@ -646,9 +633,8 @@ void general_span() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("count(a)", new CountAggregator(Arrays.asList(ref("a", INTEGER)), INTEGER))), - Arrays.asList(named(span(ref("age", INTEGER), literal(1), ""))))); + List.of(named("count(a)", new CountAggregator(List.of(ref("a", INTEGER)), INTEGER))), + List.of(named(span(ref("age", INTEGER), literal(1), ""))))); } @Test @@ -657,11 +643,9 @@ void invalid_unit() { IllegalStateException.class, () -> buildQuery( - Arrays.asList( - named( - "count(a)", - new CountAggregator(Arrays.asList(ref("a", INTEGER)), INTEGER))), - Arrays.asList(named(span(ref("age", INTEGER), literal(1), "invalid_unit"))))); + List.of( + named("count(a)", new CountAggregator(List.of(ref("a", INTEGER)), INTEGER))), + List.of(named(span(ref("age", INTEGER), literal(1), "invalid_unit"))))); } @SneakyThrows diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilderTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilderTest.java index 08c4017f1d0..b4c747e30e0 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilderTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilderTest.java @@ -14,7 +14,6 @@ import static org.opensearch.sql.expression.DSL.named; import static org.opensearch.sql.expression.DSL.ref; -import java.util.Arrays; import java.util.List; import java.util.Map; import lombok.SneakyThrows; @@ -68,7 +67,7 @@ void should_build_bucket_with_field() { + " \"order\" : \"asc\"\n" + " }\n" + "}", - buildQuery(Arrays.asList(asc(named("age", ref("age", INTEGER)))))); + buildQuery(List.of(asc(named("age", ref("age", INTEGER)))))); } @Test @@ -87,7 +86,7 @@ void should_build_bucket_with_literal() { + " \"order\" : \"asc\"\n" + " }\n" + "}", - buildQuery(Arrays.asList(asc(named(literal))))); + buildQuery(List.of(asc(named(literal))))); } @Test @@ -102,7 +101,7 @@ void should_build_bucket_with_keyword_field() { + " }\n" + "}", buildQuery( - Arrays.asList( + List.of( asc( named( "name", @@ -132,7 +131,7 @@ void should_build_bucket_with_parse_expression() { + " \"order\" : \"asc\"\n" + " }\n" + "}", - buildQuery(Arrays.asList(asc(named("name", parseExpression))))); + buildQuery(List.of(asc(named("name", parseExpression))))); } @Test @@ -149,7 +148,7 @@ void terms_bucket_for_opensearchdate_type_uses_long() { + " \"order\" : \"asc\"\n" + " }\n" + "}", - buildQuery(Arrays.asList(asc(named("date", ref("date", dataType)))))); + buildQuery(List.of(asc(named("date", ref("date", dataType)))))); } @Test @@ -165,7 +164,7 @@ void terms_bucket_for_opensearchdate_type_uses_long_false() { + " \"order\" : \"asc\"\n" + " }\n" + "}", - buildQuery(Arrays.asList(asc(named("date", ref("date", dataType)))))); + buildQuery(List.of(asc(named("date", ref("date", dataType)))))); } @ParameterizedTest(name = "{0}") @@ -183,7 +182,7 @@ void terms_bucket_for_datetime_types_uses_long(ExprType dataType) { + " \"order\" : \"asc\"\n" + " }\n" + "}", - buildQuery(Arrays.asList(asc(named("date", ref("date", dataType)))))); + buildQuery(List.of(asc(named("date", ref("date", dataType)))))); } @SneakyThrows 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 6d792dec251..0df0c8db755 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 @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableList; -import java.util.Arrays; import java.util.Collections; import java.util.List; import lombok.SneakyThrows; @@ -73,9 +72,7 @@ void should_build_avg_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "avg(age)", new AvgAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of(named("avg(age)", new AvgAggregator(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -90,9 +87,7 @@ void should_build_sum_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "sum(age)", new SumAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of(named("sum(age)", new SumAggregator(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -107,10 +102,8 @@ void should_build_count_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "count(age)", - new CountAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of( + named("count(age)", new CountAggregator(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -125,8 +118,7 @@ void should_build_count_star_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named("count(*)", new CountAggregator(Arrays.asList(literal("*")), INTEGER))))); + List.of(named("count(*)", new CountAggregator(List.of(literal("*")), INTEGER))))); } @Test @@ -140,9 +132,7 @@ void should_build_count_other_literal_aggregation() { + " }%n" + " }%n" + "}"), - buildQuery( - Arrays.asList( - named("count(1)", new CountAggregator(Arrays.asList(literal(1)), INTEGER))))); + buildQuery(List.of(named("count(1)", new CountAggregator(List.of(literal(1)), INTEGER))))); } @Test @@ -157,9 +147,7 @@ void should_build_min_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "min(age)", new MinAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of(named("min(age)", new MinAggregator(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -174,9 +162,7 @@ void should_build_max_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "max(age)", new MaxAggregator(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of(named("max(age)", new MaxAggregator(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -192,10 +178,8 @@ void should_build_varPop_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "var_pop(age)", - variancePopulation(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of( + named("var_pop(age)", variancePopulation(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -211,10 +195,8 @@ void should_build_varSamp_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "var_samp(age)", - varianceSample(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of( + named("var_samp(age)", varianceSample(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -234,11 +216,11 @@ void should_build_percentile_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( "percentile(age, 50)", new PercentileApproximateAggregator( - Arrays.asList(ref("age", INTEGER), literal(50)), DOUBLE))))); + List.of(ref("age", INTEGER), literal(50)), DOUBLE))))); } @Test @@ -258,11 +240,11 @@ void should_build_percentile_with_compression_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( "percentile(age, 50)", new PercentileApproximateAggregator( - Arrays.asList(ref("age", INTEGER), literal(50), literal(0.1)), DOUBLE))))); + List.of(ref("age", INTEGER), literal(50), literal(0.1)), DOUBLE))))); } @Test @@ -297,11 +279,11 @@ void should_build_filtered_percentile_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( "percentile(age, 50)", new PercentileApproximateAggregator( - Arrays.asList(ref("age", INTEGER), literal(50)), DOUBLE) + List.of(ref("age", INTEGER), literal(50)), DOUBLE) .condition(DSL.greater(ref("age", INTEGER), literal(30))))))); } @@ -318,10 +300,9 @@ void should_build_stddevPop_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( + List.of( named( - "stddev_pop(age)", - stddevPopulation(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + "stddev_pop(age)", stddevPopulation(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -337,10 +318,8 @@ void should_build_stddevSamp_aggregation() { + " }%n" + "}"), buildQuery( - Arrays.asList( - named( - "stddev_samp(age)", - stddevSample(Arrays.asList(ref("age", INTEGER)), INTEGER))))); + List.of( + named("stddev_samp(age)", stddevSample(List.of(ref("age", INTEGER)), INTEGER))))); } @Test @@ -483,12 +462,12 @@ void should_throw_exception_for_unsupported_distinct_aggregator() { @Test void should_throw_exception_for_unsupported_aggregator() { when(aggregator.getFunctionName()).thenReturn(new FunctionName("unsupported_agg")); - when(aggregator.getArguments()).thenReturn(Arrays.asList(ref("age", INTEGER))); + when(aggregator.getArguments()).thenReturn(List.of(ref("age", INTEGER))); IllegalStateException exception = assertThrows( IllegalStateException.class, - () -> buildQuery(Arrays.asList(named("unsupported_agg(age)", aggregator)))); + () -> buildQuery(List.of(named("unsupported_agg(age)", aggregator)))); assertEquals("unsupported aggregator unsupported_agg", exception.getMessage()); } @@ -499,11 +478,11 @@ void should_throw_exception_for_unsupported_exception() { IllegalStateException.class, () -> buildQuery( - Arrays.asList( + List.of( named( "count(age)", new CountAggregator( - Arrays.asList(named("age", ref("age", INTEGER))), INTEGER))))); + List.of(named("age", ref("age", INTEGER))), INTEGER))))); assertEquals("metric aggregation doesn't support expression age", exception.getMessage()); } 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 0db87f89d47..e79a229d00d 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 @@ -24,7 +24,7 @@ public class Utils { public static AvgAggregator avg(Expression expr, ExprCoreType type) { - return new AvgAggregator(Arrays.asList(expr), type); + return new AvgAggregator(List.of(expr), type); } public static List agg(NamedAggregator... exprs) { diff --git a/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java b/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java index 98c41027ffa..875884b69ce 100644 --- a/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java +++ b/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java @@ -237,7 +237,7 @@ public UnresolvedExpression visitTableSource(TableSourceContext ctx) { if (ctx.getChild(0) instanceof IdentsAsTableQualifiedNameContext) { return visitIdentsAsTableQualifiedName((IdentsAsTableQualifiedNameContext) ctx.getChild(0)); } else { - return visitIdentifiers(Arrays.asList(ctx)); + return visitIdentifiers(List.of(ctx)); } } 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 7c1264e0b63..b86ab0cd59b 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 @@ -8,7 +8,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.when; -import java.util.Arrays; +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(Arrays.asList(expression)); + when(project.getProjectList()).thenReturn(List.of(expression)); UnresolvedPlan plan = UnresolvedPlanHelper.addSelectAll(project); assertTrue(plan instanceof Project); diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java index ef2f2e8da8e..0f211127282 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/CsvResponseFormatterTest.java @@ -17,7 +17,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.data.model.ExprTupleValue; import org.opensearch.sql.executor.ExecutionEngine; @@ -37,7 +37,7 @@ void formatResponse() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("name", "John", "age", 20)), tupleValue(ImmutableMap.of("name", "Smith", "age", 30)))); CsvResponseFormatter formatter = new CsvResponseFormatter(); @@ -57,7 +57,7 @@ void sanitizeHeaders() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue( ImmutableMap.of( "=firstname", @@ -80,7 +80,7 @@ void sanitizeData() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("city", "Seattle")), tupleValue(ImmutableMap.of("city", "=Seattle")), tupleValue(ImmutableMap.of("city", "+Seattle")), @@ -108,7 +108,7 @@ void quoteIfRequired() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("na,me", "John,Smith", ",,age", "30,,,")), tupleValue(ImmutableMap.of("na,me", "\"Janice Jones", ",,age", "26\"")))); String expected = @@ -133,7 +133,7 @@ void escapeSanitize() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("city", "=Seattle")), tupleValue(ImmutableMap.of("city", ",,Seattle")))); String expected = "city%n=Seattle%n\",,Seattle\""; @@ -150,7 +150,7 @@ void replaceNullValues() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("name", "John", "city", "Seattle")), ExprTupleValue.fromExprValueMap( ImmutableMap.of("firstname", LITERAL_NULL, "city", stringValue("Seattle"))), diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java index ebdadcd50b5..04bf7401ceb 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/RawResponseFormatterTest.java @@ -17,7 +17,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.data.model.ExprTupleValue; import org.opensearch.sql.executor.ExecutionEngine; @@ -36,7 +36,7 @@ void formatResponse() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("name", "John", "age", 20)), tupleValue(ImmutableMap.of("name", "Smith", "age", 30)))); String expected = "name|age%n" + "John|20%n" + "Smith|30"; @@ -57,7 +57,7 @@ void sanitizeHeaders() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue( ImmutableMap.of( "=firstname", @@ -83,7 +83,7 @@ void sanitizeData() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("city", "Seattle")), tupleValue(ImmutableMap.of("city", "=Seattle")), tupleValue(ImmutableMap.of("city", "+Seattle")), @@ -120,7 +120,7 @@ void quoteIfRequired() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("na|me", "John|Smith", "||age", "30|||")), tupleValue(ImmutableMap.of("na|me", "Ja\"ne J\"ones", "||age", "\"40\"")))); String expected = @@ -152,7 +152,7 @@ void escapeSanitize() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("city", "=Seattle")), tupleValue(ImmutableMap.of("city", "||Seattle")))); String expected = "city%n" + "=Seattle%n" + "\"||Seattle\""; @@ -169,7 +169,7 @@ void senstiveCharater() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("city", "@Seattle")), tupleValue(ImmutableMap.of("city", "++Seattle")))); String expected = "city%n" + "@Seattle%n" + "++Seattle"; @@ -186,7 +186,7 @@ void senstiveCharaterWithSanitize() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("city", "@Seattle")), tupleValue(ImmutableMap.of("city", "++Seattle|||")))); String expected = "city%n" + "@Seattle%n" + "\"++Seattle|||\""; @@ -205,7 +205,7 @@ void replaceNullValues() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("name", "John", "city", "Seattle")), ExprTupleValue.fromExprValueMap( ImmutableMap.of("firstname", LITERAL_NULL, "city", stringValue("Seattle"))), diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java index e5eb0f1ac77..35435ee704a 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java @@ -16,7 +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.data.model.ExprTupleValue; import org.opensearch.sql.executor.ExecutionEngine; @@ -35,7 +35,7 @@ void formatResponse() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("firstname", "John", "age", 20)), tupleValue(ImmutableMap.of("firstname", "Smith", "age", 30)))); SimpleJsonResponseFormatter formatter = new SimpleJsonResponseFormatter(COMPACT); @@ -51,7 +51,7 @@ void formatResponsePretty() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue(ImmutableMap.of("firstname", "John", "age", 20)), tupleValue(ImmutableMap.of("firstname", "Smith", "age", 30)))); SimpleJsonResponseFormatter formatter = new SimpleJsonResponseFormatter(PRETTY); @@ -103,7 +103,7 @@ void formatResponseWithMissingValue() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( ExprTupleValue.fromExprValueMap( ImmutableMap.of("firstname", stringValue("John"), "age", LITERAL_MISSING)), tupleValue(ImmutableMap.of("firstname", "Smith", "age", 30)))); @@ -120,7 +120,7 @@ void formatResponseWithTupleValue() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue( ImmutableMap.of( "name", @@ -143,13 +143,13 @@ void formatResponseWithArrayValue() { QueryResult response = new QueryResult( schema, - Arrays.asList( + List.of( tupleValue( ImmutableMap.of( "name", "Smith", "address", - Arrays.asList( + List.of( ImmutableMap.of("state", "WA"), ImmutableMap.of("state", "NYC")))))); SimpleJsonResponseFormatter formatter = new SimpleJsonResponseFormatter(COMPACT); assertEquals( 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 d1c0be98b2a..f32aa6a6283 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 @@ -252,7 +252,7 @@ public UnresolvedExpression visitIsNullPredicate(IsNullPredicateContext ctx) { ctx.nullNotnull().NOT() == null ? IS_NULL.getName().getFunctionName() : IS_NOT_NULL.getName().getFunctionName(), - Arrays.asList(visit(ctx.predicate()))); + List.of(visit(ctx.predicate()))); } @Override