From 5045c99135d182a532b88a9e4a18ffda1cc86ddd Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Tue, 22 Aug 2023 12:49:10 -0700 Subject: [PATCH] spotless apply Signed-off-by: Mitchell Gale --- .../org/opensearch/sql/ast/dsl/AstDSL.java | 68 +++++----- .../ast/expression/NestedAllTupleFields.java | 1 - .../sql/ast/expression/QualifiedName.java | 16 +-- .../sql/ast/tree/TableFunction.java | 2 - .../sql/data/model/AbstractExprValue.java | 11 +- .../sql/data/model/ExprTimeValue.java | 3 +- .../sql/data/type/WideningTypeRule.java | 12 +- .../sql/common/utils/StringUtilsTest.java | 2 - .../sql/executor/pagination/CursorTest.java | 1 - .../MicroBatchStreamingExecutionTest.java | 2 +- .../datetime/DateTimeFunctionTest.java | 4 +- .../expression/datetime/StrToDateTest.java | 2 - .../expression/datetime/TimestampTest.java | 126 ++++++++++++------ .../function/FunctionDSLTestBase.java | 1 - .../function/FunctionDSLimplNoArgTest.java | 1 - .../function/FunctionPropertiesTest.java | 2 - .../RelevanceFunctionResolverTest.java | 2 - .../arthmetic/MathematicalFunctionTest.java | 2 +- .../BinaryPredicateOperatorTest.java | 5 - .../sql/planner/SerializablePlanTest.java | 1 - .../planner/logical/LogicalRelationTest.java | 1 - .../optimizer/pattern/PatternsTest.java | 2 - .../planner/physical/FilterOperatorTest.java | 5 - .../planner/physical/NestedOperatorTest.java | 1 - .../planner/physical/PhysicalPlanTest.java | 8 -- 25 files changed, 137 insertions(+), 144 deletions(-) diff --git a/core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java b/core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java index 2e58c6d8bf..830dbf0a65 100644 --- a/core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java +++ b/core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ - package org.opensearch.sql.ast.dsl; import java.util.Arrays; @@ -63,9 +62,7 @@ import org.opensearch.sql.ast.tree.UnresolvedPlan; import org.opensearch.sql.ast.tree.Values; -/** - * Class of static methods to create specific node instances. - */ +/** Class of static methods to create specific node instances. */ @UtilityClass public class AstDSL { @@ -132,8 +129,9 @@ public static UnresolvedPlan rename(UnresolvedPlan input, Map... maps) { /** * Initialize Values node by rows of literals. - * @param values rows in which each row is a list of literal values - * @return Values node + * + * @param values rows in which each row is a list of literal values + * @return Values node */ @SafeVarargs public UnresolvedPlan values(List... values) { @@ -259,8 +257,7 @@ public static Function function(String funcName, UnresolvedExpression... funcArg * END * */ - public UnresolvedExpression caseWhen(UnresolvedExpression elseClause, - When... whenClauses) { + public UnresolvedExpression caseWhen(UnresolvedExpression elseClause, When... whenClauses) { return caseWhen(null, elseClause, whenClauses); } @@ -275,9 +272,8 @@ public UnresolvedExpression caseWhen(UnresolvedExpression elseClause, * END * */ - public UnresolvedExpression caseWhen(UnresolvedExpression caseValueExpr, - UnresolvedExpression elseClause, - When... whenClauses) { + public UnresolvedExpression caseWhen( + UnresolvedExpression caseValueExpr, UnresolvedExpression elseClause, When... whenClauses) { return new Case(caseValueExpr, Arrays.asList(whenClauses), elseClause); } @@ -289,19 +285,20 @@ public When when(UnresolvedExpression condition, UnresolvedExpression result) { return new When(condition, result); } - public UnresolvedExpression highlight(UnresolvedExpression fieldName, - java.util.Map arguments) { + public UnresolvedExpression highlight( + UnresolvedExpression fieldName, java.util.Map arguments) { return new HighlightFunction(fieldName, arguments); } - public UnresolvedExpression score(UnresolvedExpression relevanceQuery, - Literal relevanceFieldWeight) { + public UnresolvedExpression score( + UnresolvedExpression relevanceQuery, Literal relevanceFieldWeight) { return new ScoreFunction(relevanceQuery, relevanceFieldWeight); } - public UnresolvedExpression window(UnresolvedExpression function, - List partitionByList, - List> sortList) { + public UnresolvedExpression window( + UnresolvedExpression function, + List partitionByList, + List> sortList) { return new WindowFunction(function, partitionByList, sortList); } @@ -336,9 +333,10 @@ public static UnresolvedExpression compare( return new Compare(operator, left, right); } - public static UnresolvedExpression between(UnresolvedExpression value, - UnresolvedExpression lowerBound, - UnresolvedExpression upperBound) { + public static UnresolvedExpression between( + UnresolvedExpression value, + UnresolvedExpression lowerBound, + UnresolvedExpression upperBound) { return new Between(value, lowerBound, upperBound); } @@ -406,9 +404,7 @@ public static List defaultFieldsArgs() { return exprList(argument("exclude", booleanLiteral(false))); } - /** - * Default Stats Command Args. - */ + /** Default Stats Command Args. */ public static List defaultStatsArgs() { return exprList( argument("partitions", intLiteral(1)), @@ -417,9 +413,7 @@ public static List defaultStatsArgs() { argument("dedupsplit", booleanLiteral(false))); } - /** - * Default Dedup Command Args. - */ + /** Default Dedup Command Args. */ public static List defaultDedupArgs() { return exprList( argument("number", intLiteral(1)), @@ -455,9 +449,12 @@ public static List defaultTopArgs() { return exprList(argument("noOfResults", intLiteral(10))); } - public static RareTopN rareTopN(UnresolvedPlan input, CommandType commandType, - List noOfResults, List groupList, - Field... fields) { + public static RareTopN rareTopN( + UnresolvedPlan input, + CommandType commandType, + List noOfResults, + List groupList, + Field... fields) { return new RareTopN(input, commandType, noOfResults, Arrays.asList(fields), groupList) .attach(input); } @@ -466,11 +463,12 @@ public static Limit limit(UnresolvedPlan input, Integer limit, Integer offset) { return new Limit(limit, offset).attach(input); } - public static Parse parse(UnresolvedPlan input, ParseMethod parseMethod, - UnresolvedExpression sourceField, - Literal pattern, - java.util.Map arguments) { + public static Parse parse( + UnresolvedPlan input, + ParseMethod parseMethod, + UnresolvedExpression sourceField, + Literal pattern, + java.util.Map arguments) { return new Parse(parseMethod, sourceField, pattern, arguments, input); } - } diff --git a/core/src/main/java/org/opensearch/sql/ast/expression/NestedAllTupleFields.java b/core/src/main/java/org/opensearch/sql/ast/expression/NestedAllTupleFields.java index 9449eed852..be89dd9f19 100644 --- a/core/src/main/java/org/opensearch/sql/ast/expression/NestedAllTupleFields.java +++ b/core/src/main/java/org/opensearch/sql/ast/expression/NestedAllTupleFields.java @@ -10,7 +10,6 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; -import lombok.ToString; import org.opensearch.sql.ast.AbstractNodeVisitor; import org.opensearch.sql.ast.Node; 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 9b291a14d6..55784d8113 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 @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ - package org.opensearch.sql.ast.expression; import static java.util.Objects.requireNonNull; @@ -29,9 +28,7 @@ public QualifiedName(String name) { this.parts = Collections.singletonList(name); } - /** - * QualifiedName Constructor. - */ + /** QualifiedName Constructor. */ public QualifiedName(Iterable parts) { List partsList = StreamSupport.stream(parts.spliterator(), false).collect(toList()); if (partsList.isEmpty()) { @@ -40,9 +37,7 @@ public QualifiedName(Iterable parts) { this.parts = partsList; } - /** - * Construct {@link QualifiedName} from list of string. - */ + /** Construct {@link QualifiedName} from list of string. */ public static QualifiedName of(String first, String... rest) { requireNonNull(first); ArrayList parts = new ArrayList<>(); @@ -55,9 +50,7 @@ public static QualifiedName of(Iterable parts) { return new QualifiedName(parts); } - /** - * Get Prefix of {@link QualifiedName}. - */ + /** Get Prefix of {@link QualifiedName}. */ public Optional getPrefix() { if (parts.size() == 1) { return Optional.empty(); @@ -71,7 +64,8 @@ public String getSuffix() { /** * Get first part of the qualified name. - * @return first part + * + * @return first part */ public Optional first() { if (parts.size() == 1) { diff --git a/core/src/main/java/org/opensearch/sql/ast/tree/TableFunction.java b/core/src/main/java/org/opensearch/sql/ast/tree/TableFunction.java index a193964a18..a67a943dcb 100644 --- a/core/src/main/java/org/opensearch/sql/ast/tree/TableFunction.java +++ b/core/src/main/java/org/opensearch/sql/ast/tree/TableFunction.java @@ -10,10 +10,8 @@ import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; -import lombok.Setter; import lombok.ToString; import org.opensearch.sql.ast.AbstractNodeVisitor; -import org.opensearch.sql.ast.expression.Let; import org.opensearch.sql.ast.expression.QualifiedName; import org.opensearch.sql.ast.expression.UnresolvedExpression; diff --git a/core/src/main/java/org/opensearch/sql/data/model/AbstractExprValue.java b/core/src/main/java/org/opensearch/sql/data/model/AbstractExprValue.java index 3238a26dda..f332867645 100644 --- a/core/src/main/java/org/opensearch/sql/data/model/AbstractExprValue.java +++ b/core/src/main/java/org/opensearch/sql/data/model/AbstractExprValue.java @@ -3,23 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ - package org.opensearch.sql.data.model; import org.opensearch.sql.exception.ExpressionEvaluationException; -/** - * Abstract ExprValue. - */ +/** Abstract ExprValue. */ public abstract class AbstractExprValue implements ExprValue { - /** - * The customize compareTo logic. - */ + /** The customize compareTo logic. */ @Override public int compareTo(ExprValue other) { if (this.isNull() || this.isMissing() || other.isNull() || other.isMissing()) { throw new IllegalStateException( - "[BUG] Unreachable, Comparing with NULL or MISSING is undefined"); + "[BUG] Unreachable, Comparing with NULL or MISSING is undefined"); } if ((this.isNumber() && other.isNumber()) || (this.isDateTime() && other.isDateTime()) diff --git a/core/src/main/java/org/opensearch/sql/data/model/ExprTimeValue.java b/core/src/main/java/org/opensearch/sql/data/model/ExprTimeValue.java index c22b423c7d..d808af49b1 100644 --- a/core/src/main/java/org/opensearch/sql/data/model/ExprTimeValue.java +++ b/core/src/main/java/org/opensearch/sql/data/model/ExprTimeValue.java @@ -34,8 +34,7 @@ public ExprTimeValue(String time) { this.time = LocalTime.parse(time, DATE_TIME_FORMATTER_VARIABLE_NANOS_OPTIONAL); } catch (DateTimeParseException e) { throw new SemanticCheckException( - String.format( - "time:%s in unsupported format, please use 'HH:mm:ss[.SSSSSSSSS]'", time)); + String.format("time:%s in unsupported format, please use 'HH:mm:ss[.SSSSSSSSS]'", time)); } } diff --git a/core/src/main/java/org/opensearch/sql/data/type/WideningTypeRule.java b/core/src/main/java/org/opensearch/sql/data/type/WideningTypeRule.java index c7fb70f8ec..299c35812c 100644 --- a/core/src/main/java/org/opensearch/sql/data/type/WideningTypeRule.java +++ b/core/src/main/java/org/opensearch/sql/data/type/WideningTypeRule.java @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ - package org.opensearch.sql.data.type; import static org.opensearch.sql.data.type.ExprCoreType.UNKNOWN; @@ -32,8 +31,8 @@ public class WideningTypeRule { public static final int TYPE_EQUAL = 0; /** - * The widening distance is calculated from the leaf to root. - * e.g. distance(INTEGER, FLOAT) = 2, but distance(FLOAT, INTEGER) = IMPOSSIBLE_WIDENING + * The widening distance is calculated from the leaf to root. e.g. distance(INTEGER, FLOAT) = 2, + * but distance(FLOAT, INTEGER) = IMPOSSIBLE_WIDENING * * @param type1 widen from type * @param type2 widen to type @@ -51,14 +50,15 @@ private static int distance(ExprType type1, ExprType type2, int distance) { } else { return type1.getParent().stream() .map(parentOfType1 -> distance(parentOfType1, type2, distance + 1)) - .reduce(Math::min).get(); + .reduce(Math::min) + .get(); } } /** * The max type among two types. The max is defined as follows if type1 could widen to type2, then - * max is type2, vice versa if type1 couldn't widen to type2 and type2 could't widen to type1, then - * throw {@link ExpressionEvaluationException}. + * max is type2, vice versa if type1 couldn't widen to type2 and type2 could't widen to type1, + * then throw {@link ExpressionEvaluationException}. * * @param type1 type1 * @param type2 type2 diff --git a/core/src/test/java/org/opensearch/sql/common/utils/StringUtilsTest.java b/core/src/test/java/org/opensearch/sql/common/utils/StringUtilsTest.java index 06ea404fc2..157b60cbc7 100644 --- a/core/src/test/java/org/opensearch/sql/common/utils/StringUtilsTest.java +++ b/core/src/test/java/org/opensearch/sql/common/utils/StringUtilsTest.java @@ -42,7 +42,5 @@ void unquoteTest() { assertEquals("don't", unquoteText("'don't'")); assertEquals("hello`", unquoteText("`hello``")); assertEquals("don\"t", unquoteText("\"don\"t\"")); - } - } diff --git a/core/src/test/java/org/opensearch/sql/executor/pagination/CursorTest.java b/core/src/test/java/org/opensearch/sql/executor/pagination/CursorTest.java index e3e2c8cf33..fe9590b60b 100644 --- a/core/src/test/java/org/opensearch/sql/executor/pagination/CursorTest.java +++ b/core/src/test/java/org/opensearch/sql/executor/pagination/CursorTest.java @@ -9,7 +9,6 @@ import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; -import org.opensearch.sql.executor.pagination.Cursor; @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) class CursorTest { diff --git a/core/src/test/java/org/opensearch/sql/executor/streaming/MicroBatchStreamingExecutionTest.java b/core/src/test/java/org/opensearch/sql/executor/streaming/MicroBatchStreamingExecutionTest.java index 541b3de5a0..bd0c8ed3e1 100644 --- a/core/src/test/java/org/opensearch/sql/executor/streaming/MicroBatchStreamingExecutionTest.java +++ b/core/src/test/java/org/opensearch/sql/executor/streaming/MicroBatchStreamingExecutionTest.java @@ -222,7 +222,7 @@ Helper latestOffsetLogShouldBe(Long offsetId) { * StreamingSource impl only for testing. * *

initially, offset is -1, getLatestOffset() will return Optional.emtpy(). - * + * *

call addData() add offset by one. */ static class TestStreamingSource implements StreamingSource { diff --git a/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java b/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java index fc4a2c8aa2..c2a6129626 100644 --- a/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/datetime/DateTimeFunctionTest.java @@ -503,7 +503,7 @@ public void invalidDayOfYearArgument() { assertThrows( SemanticCheckException.class, () -> invalidDayOfYearQuery("asdfasdfasdf"))); } - + @Test public void from_days() { FunctionExpression expression = DSL.from_days(DSL.literal(new ExprLongValue(730669))); @@ -1498,7 +1498,7 @@ private static Stream getInvalidTestDataForTimeFormat() { Arguments.of(DSL.literal("10:61:12"), DSL.literal("%h")), Arguments.of(DSL.literal("61:11:12"), DSL.literal("%h"))); } - + @ParameterizedTest(name = "{0}{1}") @MethodSource("getInvalidTestDataForTimeFormat") public void testInvalidTimeFormat(LiteralExpression arg, LiteralExpression format) { diff --git a/core/src/test/java/org/opensearch/sql/expression/datetime/StrToDateTest.java b/core/src/test/java/org/opensearch/sql/expression/datetime/StrToDateTest.java index dca88a70af..42d4aab1f6 100644 --- a/core/src/test/java/org/opensearch/sql/expression/datetime/StrToDateTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/datetime/StrToDateTest.java @@ -14,11 +14,9 @@ import java.time.LocalTime; import java.util.stream.Stream; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.junit.jupiter.MockitoExtension; import org.opensearch.sql.data.model.ExprDatetimeValue; import org.opensearch.sql.data.model.ExprNullValue; import org.opensearch.sql.data.model.ExprStringValue; diff --git a/core/src/test/java/org/opensearch/sql/expression/datetime/TimestampTest.java b/core/src/test/java/org/opensearch/sql/expression/datetime/TimestampTest.java index 327d59234d..7d25c0041b 100644 --- a/core/src/test/java/org/opensearch/sql/expression/datetime/TimestampTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/datetime/TimestampTest.java @@ -39,20 +39,20 @@ public void timestamp_one_arg_string() { expr = DSL.timestamp(functionProperties, DSL.literal("1961-04-12 09:07:00.123456")); assertEquals(TIMESTAMP, expr.type()); - assertEquals(LocalDateTime.of(1961, 4, 12, 9, 7, 0, 123456000), - expr.valueOf().datetimeValue()); + assertEquals(LocalDateTime.of(1961, 4, 12, 9, 7, 0, 123456000), expr.valueOf().datetimeValue()); } /** * Check that `TIMESTAMP` function throws an exception on incorrect string input. + * * @param value A value. * @param testName A test name. */ @ParameterizedTest(name = "{1}") @CsvSource({ - "1984-02-30 12:20:42, Feb 30th", - "1984-02-10 24:00:00, 24:00:00", - "84-02-10 12:20:42, 2 digit year" + "1984-02-30 12:20:42, Feb 30th", + "1984-02-10 24:00:00, 24:00:00", + "84-02-10 12:20:42, 2 digit year" }) public void timestamp_one_arg_string_invalid_format(String value, String testName) { // exception thrown from ExprTimestampValue(String) CTOR @@ -71,8 +71,7 @@ public void timestamp_one_arg_string_invalid_format(String value, String testNam public void timestamp_one_arg_time() { var expr = DSL.timestamp(functionProperties, DSL.time(DSL.literal("22:33:44"))); assertEquals(TIMESTAMP, expr.type()); - var refValue = LocalDate.now().atTime(LocalTime.of(22, 33, 44)) - .atZone(UTC_ZONE_ID).toInstant(); + var refValue = LocalDate.now().atTime(LocalTime.of(22, 33, 44)).atZone(UTC_ZONE_ID).toInstant(); assertEquals(new ExprTimestampValue(refValue), expr.valueOf()); } @@ -80,8 +79,7 @@ public void timestamp_one_arg_time() { public void timestamp_one_arg_date() { var expr = DSL.timestamp(functionProperties, DSL.date(DSL.literal("2077-12-15"))); assertEquals(TIMESTAMP, expr.type()); - var refValue = LocalDate.of(2077, 12, 15).atStartOfDay() - .atZone(UTC_ZONE_ID).toInstant(); + var refValue = LocalDate.of(2077, 12, 15).atStartOfDay().atZone(UTC_ZONE_ID).toInstant(); assertEquals(new ExprTimestampValue(refValue), expr.valueOf()); } @@ -95,8 +93,8 @@ public void timestamp_one_arg_datetime() { @Test public void timestamp_one_arg_timestamp() { var refValue = new ExprTimestampValue(Instant.ofEpochSecond(10050042)); - var expr = DSL.timestamp(functionProperties, - DSL.timestamp(functionProperties, DSL.literal(refValue))); + var expr = + DSL.timestamp(functionProperties, DSL.timestamp(functionProperties, DSL.literal(refValue))); assertEquals(TIMESTAMP, expr.type()); assertEquals(refValue, expr.valueOf()); } @@ -114,71 +112,115 @@ private static Stream getTestData() { // First argument of `TIMESTAMP` function, second argument and expected result value return Stream.of( // STRING and STRING/DATE/TIME/DATETIME/TIMESTAMP - Arguments.of("1961-04-12 09:07:00", "2077-12-15 01:48:00", + Arguments.of( + "1961-04-12 09:07:00", + "2077-12-15 01:48:00", dateTime2ExprTs(LocalDateTime.of(1961, 4, 12, 10, 55, 0))), - Arguments.of("1984-02-10 12:20:42", LocalDate.of(2077, 12, 21), + Arguments.of( + "1984-02-10 12:20:42", + LocalDate.of(2077, 12, 21), dateTime2ExprTs(LocalDateTime.of(1984, 2, 10, 12, 20, 42))), - Arguments.of("1961-04-12 09:07:00", LocalTime.of(1, 48), + Arguments.of( + "1961-04-12 09:07:00", + LocalTime.of(1, 48), dateTime2ExprTs(LocalDateTime.of(1961, 4, 12, 10, 55, 0))), - Arguments.of("2020-12-31 17:30:00", LocalDateTime.of(2077, 12, 21, 12, 20, 42), + Arguments.of( + "2020-12-31 17:30:00", + LocalDateTime.of(2077, 12, 21, 12, 20, 42), dateTime2ExprTs(LocalDateTime.of(2021, 1, 1, 5, 50, 42))), - Arguments.of("2020-12-31 17:30:00", Instant.ofEpochSecond(42), + Arguments.of( + "2020-12-31 17:30:00", + Instant.ofEpochSecond(42), dateTime2ExprTs(LocalDateTime.of(2020, 12, 31, 17, 30, 42))), // DATE and STRING/DATE/TIME/DATETIME/TIMESTAMP - Arguments.of(LocalDate.of(2077, 12, 21), "2077-12-15 01:48:00", + Arguments.of( + LocalDate.of(2077, 12, 21), + "2077-12-15 01:48:00", dateTime2ExprTs(LocalDateTime.of(2077, 12, 21, 1, 48, 0))), - Arguments.of(LocalDate.of(2077, 12, 21), LocalDate.of(1984, 2, 3), + Arguments.of( + LocalDate.of(2077, 12, 21), + LocalDate.of(1984, 2, 3), dateTime2ExprTs(LocalDateTime.of(2077, 12, 21, 0, 0, 0))), - Arguments.of(LocalDate.of(2077, 12, 21), LocalTime.of(22, 33, 44), + Arguments.of( + LocalDate.of(2077, 12, 21), + LocalTime.of(22, 33, 44), dateTime2ExprTs(LocalDateTime.of(2077, 12, 21, 22, 33, 44))), - Arguments.of(LocalDate.of(2077, 12, 21), LocalDateTime.of(1999, 9, 9, 22, 33, 44), + Arguments.of( + LocalDate.of(2077, 12, 21), + LocalDateTime.of(1999, 9, 9, 22, 33, 44), dateTime2ExprTs(LocalDateTime.of(2077, 12, 21, 22, 33, 44))), - Arguments.of(LocalDate.of(2077, 12, 21), Instant.ofEpochSecond(42), + Arguments.of( + LocalDate.of(2077, 12, 21), + Instant.ofEpochSecond(42), dateTime2ExprTs(LocalDateTime.of(2077, 12, 21, 0, 0, 42))), // TIME and STRING/DATE/TIME/DATETIME/TIMESTAMP - Arguments.of(LocalTime.of(9, 7, 0), "2077-12-15 01:48:00", + Arguments.of( + LocalTime.of(9, 7, 0), + "2077-12-15 01:48:00", dateTime2ExprTs(today.atTime(LocalTime.of(10, 55, 0)))), - Arguments.of(LocalTime.of(12, 20, 42), LocalDate.of(2077, 12, 21), + Arguments.of( + LocalTime.of(12, 20, 42), + LocalDate.of(2077, 12, 21), dateTime2ExprTs(today.atTime(LocalTime.of(12, 20, 42)))), - Arguments.of(LocalTime.of(9, 7, 0), LocalTime.of(1, 48), + Arguments.of( + LocalTime.of(9, 7, 0), + LocalTime.of(1, 48), dateTime2ExprTs(today.atTime(LocalTime.of(10, 55, 0)))), - Arguments.of(LocalTime.of(17, 30, 0), LocalDateTime.of(2077, 12, 21, 12, 20, 42), + Arguments.of( + LocalTime.of(17, 30, 0), + LocalDateTime.of(2077, 12, 21, 12, 20, 42), dateTime2ExprTs(today.plusDays(1).atTime(LocalTime.of(5, 50, 42)))), - Arguments.of(LocalTime.of(17, 30, 0), Instant.ofEpochSecond(42), + Arguments.of( + LocalTime.of(17, 30, 0), + Instant.ofEpochSecond(42), dateTime2ExprTs(today.atTime(LocalTime.of(17, 30, 42)))), // DATETIME and STRING/DATE/TIME/DATETIME/TIMESTAMP - Arguments.of(LocalDateTime.of(1961, 4, 12, 9, 7, 0), "2077-12-15 01:48:00", + Arguments.of( + LocalDateTime.of(1961, 4, 12, 9, 7, 0), + "2077-12-15 01:48:00", dateTime2ExprTs(LocalDateTime.of(1961, 4, 12, 10, 55, 0))), - Arguments.of(LocalDateTime.of(1984, 2, 10, 12, 20, 42), LocalDate.of(2077, 12, 21), + Arguments.of( + LocalDateTime.of(1984, 2, 10, 12, 20, 42), + LocalDate.of(2077, 12, 21), dateTime2ExprTs(LocalDateTime.of(1984, 2, 10, 12, 20, 42))), - Arguments.of(LocalDateTime.of(1961, 4, 12, 9, 7, 0), LocalTime.of(1, 48), + Arguments.of( + LocalDateTime.of(1961, 4, 12, 9, 7, 0), + LocalTime.of(1, 48), dateTime2ExprTs(LocalDateTime.of(1961, 4, 12, 10, 55, 0))), - Arguments.of(LocalDateTime.of(2020, 12, 31, 17, 30, 0), + Arguments.of( + LocalDateTime.of(2020, 12, 31, 17, 30, 0), LocalDateTime.of(2077, 12, 21, 12, 20, 42), dateTime2ExprTs(LocalDateTime.of(2021, 1, 1, 5, 50, 42))), - Arguments.of(LocalDateTime.of(2020, 12, 31, 17, 30, 0), Instant.ofEpochSecond(42), + Arguments.of( + LocalDateTime.of(2020, 12, 31, 17, 30, 0), + Instant.ofEpochSecond(42), dateTime2ExprTs(LocalDateTime.of(2020, 12, 31, 17, 30, 42))), // TIMESTAMP and STRING/DATE/TIME/DATETIME/TIMESTAMP - Arguments.of(dateTime2Instant(LocalDateTime.of(1961, 4, 12, 9, 7, 0)), + Arguments.of( + dateTime2Instant(LocalDateTime.of(1961, 4, 12, 9, 7, 0)), "2077-12-15 01:48:00", dateTime2ExprTs(LocalDateTime.of(1961, 4, 12, 10, 55, 0))), - Arguments.of(dateTime2Instant(LocalDateTime.of(1984, 2, 10, 12, 20, 42)), + Arguments.of( + dateTime2Instant(LocalDateTime.of(1984, 2, 10, 12, 20, 42)), LocalDate.of(2077, 12, 21), dateTime2ExprTs(LocalDateTime.of(1984, 2, 10, 12, 20, 42))), - Arguments.of(dateTime2Instant(LocalDateTime.of(1961, 4, 12, 9, 7, 0)), + Arguments.of( + dateTime2Instant(LocalDateTime.of(1961, 4, 12, 9, 7, 0)), LocalTime.of(1, 48), dateTime2ExprTs(LocalDateTime.of(1961, 4, 12, 10, 55, 0))), - Arguments.of(dateTime2Instant(LocalDateTime.of(2020, 12, 31, 17, 30, 0)), + Arguments.of( + dateTime2Instant(LocalDateTime.of(2020, 12, 31, 17, 30, 0)), LocalDateTime.of(2077, 12, 21, 12, 20, 42), dateTime2ExprTs(LocalDateTime.of(2021, 1, 1, 5, 50, 42))), - Arguments.of(dateTime2Instant(LocalDateTime.of(2020, 12, 31, 17, 30, 0)), + Arguments.of( + dateTime2Instant(LocalDateTime.of(2020, 12, 31, 17, 30, 0)), Instant.ofEpochSecond(42), - dateTime2ExprTs(LocalDateTime.of(2020, 12, 31, 17, 30, 42))) - ); + dateTime2ExprTs(LocalDateTime.of(2020, 12, 31, 17, 30, 42)))); } /** * Test `TIMESTAMP` function which takes 2 arguments with input of different types. + * * @param arg1 First argument to be passed to `TIMESTAMP` function. * @param arg2 Second argument to be passed to `TIMESTAMP` function. * @param expected The expected result. @@ -186,9 +228,11 @@ private static Stream getTestData() { @ParameterizedTest @MethodSource("getTestData") public void timestamp_with_two_args(Object arg1, Object arg2, ExprTimestampValue expected) { - var expr = DSL.timestamp(functionProperties, - DSL.literal(ExprValueUtils.fromObjectValue(arg1)), - DSL.literal(ExprValueUtils.fromObjectValue(arg2))); + var expr = + DSL.timestamp( + functionProperties, + DSL.literal(ExprValueUtils.fromObjectValue(arg1)), + DSL.literal(ExprValueUtils.fromObjectValue(arg2))); assertEquals(TIMESTAMP, expr.type()); assertEquals(expected, expr.valueOf()); } diff --git a/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLTestBase.java b/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLTestBase.java index e5bffc8c0e..a8b9e8da96 100644 --- a/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLTestBase.java +++ b/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLTestBase.java @@ -11,7 +11,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.opensearch.sql.data.model.ExprMissingValue; import org.opensearch.sql.data.model.ExprNullValue; -import org.opensearch.sql.data.model.ExprTupleValue; import org.opensearch.sql.data.model.ExprValue; import org.opensearch.sql.data.type.ExprCoreType; import org.opensearch.sql.data.type.ExprType; diff --git a/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLimplNoArgTest.java b/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLimplNoArgTest.java index 5d970803ed..907cd49f26 100644 --- a/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLimplNoArgTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/function/FunctionDSLimplNoArgTest.java @@ -9,7 +9,6 @@ import java.util.List; import org.apache.commons.lang3.tuple.Pair; -import org.junit.jupiter.api.BeforeEach; import org.opensearch.sql.expression.Expression; class FunctionDSLimplNoArgTest extends FunctionDSLimplTestBase { diff --git a/core/src/test/java/org/opensearch/sql/expression/function/FunctionPropertiesTest.java b/core/src/test/java/org/opensearch/sql/expression/function/FunctionPropertiesTest.java index 599b9a984f..b531d049fd 100644 --- a/core/src/test/java/org/opensearch/sql/expression/function/FunctionPropertiesTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/function/FunctionPropertiesTest.java @@ -17,9 +17,7 @@ import java.time.Clock; import java.time.Instant; import java.time.ZoneId; -import java.util.concurrent.Callable; import java.util.function.Consumer; -import java.util.function.Function; import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DynamicTest; diff --git a/core/src/test/java/org/opensearch/sql/expression/function/RelevanceFunctionResolverTest.java b/core/src/test/java/org/opensearch/sql/expression/function/RelevanceFunctionResolverTest.java index 35fb562a3c..c678ac6eb4 100644 --- a/core/src/test/java/org/opensearch/sql/expression/function/RelevanceFunctionResolverTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/function/RelevanceFunctionResolverTest.java @@ -6,9 +6,7 @@ package org.opensearch.sql.expression.function; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opensearch.sql.data.type.ExprCoreType.INTEGER; import static org.opensearch.sql.data.type.ExprCoreType.STRING; diff --git a/core/src/test/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunctionTest.java b/core/src/test/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunctionTest.java index c3d310807e..e084bf1d53 100644 --- a/core/src/test/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunctionTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/operator/arthmetic/MathematicalFunctionTest.java @@ -1174,7 +1174,7 @@ public void signum_double_value(Double value) { assertThat( signum.valueOf(valueEnv()), allOf(hasType(INTEGER), hasValue((int) Math.signum(value)))); assertEquals(String.format("signum(%s)", value), signum.toString()); - } + } /** Test sinh with byte value. */ @ParameterizedTest(name = "sinh({0})") diff --git a/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java b/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java index 012cf9a6c2..e6290553ce 100644 --- a/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java @@ -10,10 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.opensearch.sql.config.TestConfig.BOOL_TYPE_MISSING_VALUE_FIELD; import static org.opensearch.sql.config.TestConfig.BOOL_TYPE_NULL_VALUE_FIELD; -import static org.opensearch.sql.config.TestConfig.INT_TYPE_MISSING_VALUE_FIELD; -import static org.opensearch.sql.config.TestConfig.INT_TYPE_NULL_VALUE_FIELD; -import static org.opensearch.sql.config.TestConfig.STRING_TYPE_MISSING_VALUE_FIELD; -import static org.opensearch.sql.config.TestConfig.STRING_TYPE_NULL_VALUE_FIELD; import static org.opensearch.sql.data.model.ExprValueUtils.LITERAL_FALSE; import static org.opensearch.sql.data.model.ExprValueUtils.LITERAL_MISSING; import static org.opensearch.sql.data.model.ExprValueUtils.LITERAL_NULL; @@ -24,7 +20,6 @@ import static org.opensearch.sql.data.type.ExprCoreType.BOOLEAN; import static org.opensearch.sql.data.type.ExprCoreType.DATETIME; import static org.opensearch.sql.data.type.ExprCoreType.INTEGER; -import static org.opensearch.sql.data.type.ExprCoreType.STRING; import static org.opensearch.sql.data.type.ExprCoreType.STRUCT; import static org.opensearch.sql.data.type.ExprCoreType.TIMESTAMP; import static org.opensearch.sql.utils.ComparisonUtil.compare; diff --git a/core/src/test/java/org/opensearch/sql/planner/SerializablePlanTest.java b/core/src/test/java/org/opensearch/sql/planner/SerializablePlanTest.java index 8073445dc0..f00ef61ee1 100644 --- a/core/src/test/java/org/opensearch/sql/planner/SerializablePlanTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/SerializablePlanTest.java @@ -6,7 +6,6 @@ package org.opensearch.sql.planner; import static org.junit.jupiter.api.Assertions.assertSame; -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Answers.CALLS_REAL_METHODS; import org.junit.jupiter.api.DisplayNameGeneration; diff --git a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java index b5ff9d16b7..7181c91da9 100644 --- a/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/logical/LogicalRelationTest.java @@ -11,7 +11,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.opensearch.sql.expression.Expression; import org.opensearch.sql.storage.Table; @ExtendWith(MockitoExtension.class) diff --git a/core/src/test/java/org/opensearch/sql/planner/optimizer/pattern/PatternsTest.java b/core/src/test/java/org/opensearch/sql/planner/optimizer/pattern/PatternsTest.java index 6802983397..d1e1a03521 100644 --- a/core/src/test/java/org/opensearch/sql/planner/optimizer/pattern/PatternsTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/optimizer/pattern/PatternsTest.java @@ -7,7 +7,6 @@ import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -16,7 +15,6 @@ import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; import org.opensearch.sql.planner.logical.LogicalFilter; -import org.opensearch.sql.planner.logical.LogicalPaginate; import org.opensearch.sql.planner.logical.LogicalPlan; @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/FilterOperatorTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/FilterOperatorTest.java index 43e41c2a24..bfe3b323c4 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/FilterOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/FilterOperatorTest.java @@ -16,17 +16,12 @@ import com.google.common.collect.ImmutableMap; import java.util.LinkedHashMap; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.AdditionalAnswers; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import org.opensearch.sql.data.model.ExprIntegerValue; import org.opensearch.sql.data.model.ExprTupleValue; import org.opensearch.sql.data.model.ExprValue; import org.opensearch.sql.data.model.ExprValueUtils; diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/NestedOperatorTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/NestedOperatorTest.java index a270b4d5dc..cf98183eb3 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/NestedOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/NestedOperatorTest.java @@ -8,7 +8,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; 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.collectionValue; import static org.opensearch.sql.data.model.ExprValueUtils.tupleValue; diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java index 6a802a25c5..d63ab35773 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java @@ -5,15 +5,7 @@ package org.opensearch.sql.planner.physical; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.CALLS_REAL_METHODS; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import java.util.List; import org.junit.jupiter.api.DisplayNameGeneration;