Skip to content

Commit

Permalink
spotless apply
Browse files Browse the repository at this point in the history
Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Aug 22, 2023
1 parent 430dd90 commit 5045c99
Show file tree
Hide file tree
Showing 25 changed files with 137 additions and 144 deletions.
68 changes: 33 additions & 35 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.dsl;

import java.util.Arrays;
Expand Down Expand Up @@ -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 {

Expand Down Expand Up @@ -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<Literal>... values) {
Expand Down Expand Up @@ -259,8 +257,7 @@ public static Function function(String funcName, UnresolvedExpression... funcArg
* END
* </pre>
*/
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause,
When... whenClauses) {
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause, When... whenClauses) {
return caseWhen(null, elseClause, whenClauses);
}

Expand All @@ -275,9 +272,8 @@ public UnresolvedExpression caseWhen(UnresolvedExpression elseClause,
* END
* </pre>
*/
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);
}

Expand All @@ -289,19 +285,20 @@ public When when(UnresolvedExpression condition, UnresolvedExpression result) {
return new When(condition, result);
}

public UnresolvedExpression highlight(UnresolvedExpression fieldName,
java.util.Map<String, Literal> arguments) {
public UnresolvedExpression highlight(
UnresolvedExpression fieldName, java.util.Map<String, Literal> 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<UnresolvedExpression> partitionByList,
List<Pair<SortOption, UnresolvedExpression>> sortList) {
public UnresolvedExpression window(
UnresolvedExpression function,
List<UnresolvedExpression> partitionByList,
List<Pair<SortOption, UnresolvedExpression>> sortList) {
return new WindowFunction(function, partitionByList, sortList);
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -406,9 +404,7 @@ public static List<Argument> defaultFieldsArgs() {
return exprList(argument("exclude", booleanLiteral(false)));
}

/**
* Default Stats Command Args.
*/
/** Default Stats Command Args. */
public static List<Argument> defaultStatsArgs() {
return exprList(
argument("partitions", intLiteral(1)),
Expand All @@ -417,9 +413,7 @@ public static List<Argument> defaultStatsArgs() {
argument("dedupsplit", booleanLiteral(false)));
}

/**
* Default Dedup Command Args.
*/
/** Default Dedup Command Args. */
public static List<Argument> defaultDedupArgs() {
return exprList(
argument("number", intLiteral(1)),
Expand Down Expand Up @@ -455,9 +449,12 @@ public static List<Argument> defaultTopArgs() {
return exprList(argument("noOfResults", intLiteral(10)));
}

public static RareTopN rareTopN(UnresolvedPlan input, CommandType commandType,
List<Argument> noOfResults, List<UnresolvedExpression> groupList,
Field... fields) {
public static RareTopN rareTopN(
UnresolvedPlan input,
CommandType commandType,
List<Argument> noOfResults,
List<UnresolvedExpression> groupList,
Field... fields) {
return new RareTopN(input, commandType, noOfResults, Arrays.asList(fields), groupList)
.attach(input);
}
Expand All @@ -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<String, Literal> arguments) {
public static Parse parse(
UnresolvedPlan input,
ParseMethod parseMethod,
UnresolvedExpression sourceField,
Literal pattern,
java.util.Map<String, Literal> arguments) {
return new Parse(parseMethod, sourceField, pattern, arguments, input);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


package org.opensearch.sql.ast.expression;

import static java.util.Objects.requireNonNull;
Expand All @@ -29,9 +28,7 @@ public QualifiedName(String name) {
this.parts = Collections.singletonList(name);
}

/**
* QualifiedName Constructor.
*/
/** QualifiedName Constructor. */
public QualifiedName(Iterable<String> parts) {
List<String> partsList = StreamSupport.stream(parts.spliterator(), false).collect(toList());
if (partsList.isEmpty()) {
Expand All @@ -40,9 +37,7 @@ public QualifiedName(Iterable<String> 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<String> parts = new ArrayList<>();
Expand All @@ -55,9 +50,7 @@ public static QualifiedName of(Iterable<String> parts) {
return new QualifiedName(parts);
}

/**
* Get Prefix of {@link QualifiedName}.
*/
/** Get Prefix of {@link QualifiedName}. */
public Optional<QualifiedName> getPrefix() {
if (parts.size() == 1) {
return Optional.empty();
Expand All @@ -71,7 +64,8 @@ public String getSuffix() {

/**
* Get first part of the qualified name.
* @return first part
*
* @return first part
*/
public Optional<String> first() {
if (parts.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,5 @@ void unquoteTest() {
assertEquals("don't", unquoteText("'don't'"));
assertEquals("hello`", unquoteText("`hello``"));
assertEquals("don\"t", unquoteText("\"don\"t\""));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Helper latestOffsetLogShouldBe(Long offsetId) {
* StreamingSource impl only for testing.
*
* <p>initially, offset is -1, getLatestOffset() will return Optional.emtpy().
*
*
* <p>call addData() add offset by one.
*/
static class TestStreamingSource implements StreamingSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -1498,7 +1498,7 @@ private static Stream<Arguments> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 5045c99

Please sign in to comment.