Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] [Spotless] Applying Google Code Format for core #5 (#1951) #1996

Merged
merged 4 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,7 @@ repositories {
spotless {
java {
target fileTree('.') {
include 'core/src/main/java/org/opensearch/sql/monitor/**/*.java',
'core/src/main/java/org/opensearch/sql/expression/**/*.java',
'core/src/main/java/org/opensearch/sql/executor/**/*.java',
'core/src/main/java/org/opensearch/sql/exception/**/*.java',
'core/src/main/java/org/opensearch/sql/DataSourceSchemaName.java',
'core/src/test/java/org/opensearch/sql/data/**/*.java',
'core/src/test/java/org/opensearch/sql/config/**/*.java',
'core/src/test/java/org/opensearch/sql/analysis/**/*.java',
'core/src/main/java/org/opensearch/sql/planner/**/*.java',
'core/src/main/java/org/opensearch/sql/storage/**/*.java',
'core/src/main/java/org/opensearch/sql/utils/**/*.java'
include 'core/**/*.java'
exclude '**/build/**', '**/build-*/**'
}
importOrder()
Expand Down
7 changes: 6 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ repositories {
mavenCentral()
}

checkstyleMain.ignoreFailures = true
// Being ignored as a temporary measure before being removed in favour of
// spotless https://github.com/opensearch-project/sql/issues/1101
checkstyleTest.ignoreFailures = true
checkstyleMain.ignoreFailures = true
checkstyleTestFixtures.ignoreFailures = true



dependencies {
api group: 'com.google.guava', name: 'guava', version: '32.0.1-jre'
Expand Down
78 changes: 40 additions & 38 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 @@ -249,20 +247,23 @@ public static Function function(String funcName, UnresolvedExpression... funcArg
}

/**
*
*
* <pre>
* CASE
* WHEN search_condition THEN result_expr<br>
* [WHEN search_condition THEN result_expr] ...
* [ELSE result_expr]
* WHEN search_condition THEN result_expr
* [WHEN search_condition THEN result_expr] ...
* [ELSE result_expr]
* END
* </pre>
*/
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause,
When... whenClauses) {
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause, When... whenClauses) {
return caseWhen(null, elseClause, whenClauses);
}

/**
*
*
* <pre>
* CASE case_value_expr
* WHEN compare_expr THEN result_expr
Expand All @@ -271,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 @@ -285,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 @@ -332,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 @@ -402,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 @@ -413,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 @@ -451,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 @@ -462,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 @@ -75,17 +75,19 @@ public Optional<String> first() {
}

/**
* <pre>
* Get rest parts of the qualified name. Assume that there must be remaining parts so caller is
* responsible for the check (first() or size() must be called first).<br>
* For example:<br>
* {@code<br>
* &nbsp; QualifiedName name = ...<br>
* &nbsp; Optional<String> first = name.first();<br>
* &nbsp; if (first.isPresent()) {<br>
* &ensp; name.rest() ...<br>
* &nbsp; }<br>
* responsible for the check (first() or size() must be called first).
* For example:
* {@code
* QualifiedName name = ...
* Optional<String> first = name.first();
* if (first.isPresent()) {
* name.rest() ...
* }
* @return rest part(s)
* }
* @return rest part(s)
* </pre>
*/
public QualifiedName rest() {
return QualifiedName.of(parts.subList(1, parts.size()));
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 @@ -29,8 +29,9 @@ public int compareTo(ExprValue other) {
}

/**
* The customize equals logic.
* The customize equals logic.<br>
* The table below list the NULL and MISSING handling logic.
*
* <table>
* <tr>
* <th>A</th>
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 All @@ -13,6 +12,7 @@

/**
* The definition of widening type rule for expression value.
*
* <table border="3">
* <tr><th>ExprType</th><th>Widens to data types</th></tr>
* <tr><td>INTEGER</td><td>LONG, FLOAT, DOUBLE</td></tr>
Expand All @@ -31,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 @@ -50,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 follow 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}.
* 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}.
*
* @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\""));

}

}
Loading