Skip to content

Commit

Permalink
Integ/sl google java format5 (#332)
Browse files Browse the repository at this point in the history
Adding core final GJF fix.

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
  • Loading branch information
MitchellGale committed Aug 9, 2023
1 parent 7d23e0f commit 8358445
Show file tree
Hide file tree
Showing 131 changed files with 5,517 additions and 5,645 deletions.
16 changes: 1 addition & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,7 @@ repositories {
spotless {
java {
target fileTree('.') {
include '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',
'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/analysis/**/*.java',
'core/src/test/java/org/opensearch/sql/data/**/*.java',
'core/src/test/java/org/opensearch/sql/datasource/**/*.java',
'core/src/test/java/org/opensearch/sql/ast/**/*.java'
include 'core/**/*.java'
exclude '**/build/**', '**/build-*/**'
}
importOrder()
Expand Down
3 changes: 3 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ dependencies {
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4'
}

checkstyleMain.ignoreFailures = true
checkstyleTest.ignoreFailures = true

test {
useJUnitPlatform()
testLogging {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ public static Function function(String funcName, UnresolvedExpression... funcArg
* [WHEN search_condition THEN result_expr] ...
* [ELSE result_expr]
* END
* </pre>
*/
public UnresolvedExpression caseWhen(UnresolvedExpression elseClause,
When... whenClauses) {
Expand All @@ -269,7 +268,6 @@ public UnresolvedExpression caseWhen(UnresolvedExpression elseClause,
* [WHEN compare_expr THEN result_expr] ...
* [ELSE result_expr]
* END
* </pre>
*/
public UnresolvedExpression caseWhen(UnresolvedExpression caseValueExpr,
UnresolvedExpression elseClause,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
* 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 All @@ -29,7 +34,7 @@ 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>
Expand Down Expand Up @@ -76,9 +81,13 @@ public boolean equals(Object o) {
}
}

/** The expression value compare. */
/**
* The expression value compare.
*/
public abstract int compare(ExprValue other);

/** The expression value equal. */
/**
* The expression value equal.
*/
public abstract boolean equal(ExprValue other);
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ protected Boolean canPaginate(Node node, Object context) {
// https://github.com/opensearch-project/sql/issues/1471
@Override
public Boolean visitSort(Sort node, Object context) {
return node.getSortList().stream()
.allMatch(f -> f.getField() instanceof QualifiedName && visitField(f, context))
return node.getSortList().stream().allMatch(f -> f.getField() instanceof QualifiedName
&& visitField(f, context))
&& canPaginate(node, context);
}

Expand Down Expand Up @@ -124,8 +124,8 @@ public Boolean visitLiteral(Literal node, Object context) {

@Override
public Boolean visitField(Field node, Object context) {
return canPaginate(node, context)
&& node.getFieldArgs().stream().allMatch(n -> n.accept(this, context));
return canPaginate(node, context) && node.getFieldArgs().stream()
.allMatch(n -> n.accept(this, context));
}

@Override
Expand Down Expand Up @@ -200,8 +200,8 @@ public Boolean visitFunction(Function node, Object context) {

@Override
public Boolean visitIn(In node, Object context) {
return canPaginate(node, context)
&& node.getValueList().stream().allMatch(n -> n.accept(this, context));
return canPaginate(node, context) && node.getValueList().stream()
.allMatch(n -> n.accept(this, context));
}

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


package org.opensearch.sql.expression.aggregation;

import static org.opensearch.sql.data.type.ExprCoreType.ARRAY;
Expand Down Expand Up @@ -65,37 +66,26 @@ private static DefaultFunctionResolver avg() {
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> new AvgAggregator(arguments, DOUBLE))
.put(
new FunctionSignature(functionName, Collections.singletonList(DATE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DATE)),
(functionProperties, arguments) -> new AvgAggregator(arguments, DATE))
.put(
new FunctionSignature(functionName, Collections.singletonList(DATETIME)),
.put(new FunctionSignature(functionName, Collections.singletonList(DATETIME)),
(functionProperties, arguments) -> new AvgAggregator(arguments, DATETIME))
.put(
new FunctionSignature(functionName, Collections.singletonList(TIME)),
.put(new FunctionSignature(functionName, Collections.singletonList(TIME)),
(functionProperties, arguments) -> new AvgAggregator(arguments, TIME))
.put(
new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)),
.put(new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)),
(functionProperties, arguments) -> new AvgAggregator(arguments, TIMESTAMP))
.build());
.build()
);
}

private static DefaultFunctionResolver count() {
FunctionName functionName = BuiltinFunctionName.COUNT.getName();
DefaultFunctionResolver functionResolver =
new DefaultFunctionResolver(
functionName,
ExprCoreType.coreTypes().stream()
.collect(
Collectors.toMap(
type ->
new FunctionSignature(functionName, Collections.singletonList(type)),
type ->
(functionProperties, arguments) ->
new CountAggregator(arguments, INTEGER))));
DefaultFunctionResolver functionResolver = new DefaultFunctionResolver(functionName,
ExprCoreType.coreTypes().stream().collect(Collectors.toMap(
type -> new FunctionSignature(functionName, Collections.singletonList(type)),
type -> (functionProperties, arguments) -> new CountAggregator(arguments, INTEGER))));
return functionResolver;
}

Expand All @@ -104,52 +94,40 @@ private static DefaultFunctionResolver sum() {
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(INTEGER)),
.put(new FunctionSignature(functionName, Collections.singletonList(INTEGER)),
(functionProperties, arguments) -> new SumAggregator(arguments, INTEGER))
.put(
new FunctionSignature(functionName, Collections.singletonList(LONG)),
.put(new FunctionSignature(functionName, Collections.singletonList(LONG)),
(functionProperties, arguments) -> new SumAggregator(arguments, LONG))
.put(
new FunctionSignature(functionName, Collections.singletonList(FLOAT)),
.put(new FunctionSignature(functionName, Collections.singletonList(FLOAT)),
(functionProperties, arguments) -> new SumAggregator(arguments, FLOAT))
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> new SumAggregator(arguments, DOUBLE))
.build());
.build()
);
}

private static DefaultFunctionResolver min() {
FunctionName functionName = BuiltinFunctionName.MIN.getName();
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(INTEGER)),
.put(new FunctionSignature(functionName, Collections.singletonList(INTEGER)),
(functionProperties, arguments) -> new MinAggregator(arguments, INTEGER))
.put(
new FunctionSignature(functionName, Collections.singletonList(LONG)),
.put(new FunctionSignature(functionName, Collections.singletonList(LONG)),
(functionProperties, arguments) -> new MinAggregator(arguments, LONG))
.put(
new FunctionSignature(functionName, Collections.singletonList(FLOAT)),
.put(new FunctionSignature(functionName, Collections.singletonList(FLOAT)),
(functionProperties, arguments) -> new MinAggregator(arguments, FLOAT))
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> new MinAggregator(arguments, DOUBLE))
.put(
new FunctionSignature(functionName, Collections.singletonList(STRING)),
.put(new FunctionSignature(functionName, Collections.singletonList(STRING)),
(functionProperties, arguments) -> new MinAggregator(arguments, STRING))
.put(
new FunctionSignature(functionName, Collections.singletonList(DATE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DATE)),
(functionProperties, arguments) -> new MinAggregator(arguments, DATE))
.put(
new FunctionSignature(functionName, Collections.singletonList(DATETIME)),
.put(new FunctionSignature(functionName, Collections.singletonList(DATETIME)),
(functionProperties, arguments) -> new MinAggregator(arguments, DATETIME))
.put(
new FunctionSignature(functionName, Collections.singletonList(TIME)),
.put(new FunctionSignature(functionName, Collections.singletonList(TIME)),
(functionProperties, arguments) -> new MinAggregator(arguments, TIME))
.put(
new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)),
.put(new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)),
(functionProperties, arguments) -> new MinAggregator(arguments, TIMESTAMP))
.build());
}
Expand All @@ -159,90 +137,80 @@ private static DefaultFunctionResolver max() {
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(INTEGER)),
.put(new FunctionSignature(functionName, Collections.singletonList(INTEGER)),
(functionProperties, arguments) -> new MaxAggregator(arguments, INTEGER))
.put(
new FunctionSignature(functionName, Collections.singletonList(LONG)),
.put(new FunctionSignature(functionName, Collections.singletonList(LONG)),
(functionProperties, arguments) -> new MaxAggregator(arguments, LONG))
.put(
new FunctionSignature(functionName, Collections.singletonList(FLOAT)),
.put(new FunctionSignature(functionName, Collections.singletonList(FLOAT)),
(functionProperties, arguments) -> new MaxAggregator(arguments, FLOAT))
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> new MaxAggregator(arguments, DOUBLE))
.put(
new FunctionSignature(functionName, Collections.singletonList(STRING)),
.put(new FunctionSignature(functionName, Collections.singletonList(STRING)),
(functionProperties, arguments) -> new MaxAggregator(arguments, STRING))
.put(
new FunctionSignature(functionName, Collections.singletonList(DATE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DATE)),
(functionProperties, arguments) -> new MaxAggregator(arguments, DATE))
.put(
new FunctionSignature(functionName, Collections.singletonList(DATETIME)),
.put(new FunctionSignature(functionName, Collections.singletonList(DATETIME)),
(functionProperties, arguments) -> new MaxAggregator(arguments, DATETIME))
.put(
new FunctionSignature(functionName, Collections.singletonList(TIME)),
.put(new FunctionSignature(functionName, Collections.singletonList(TIME)),
(functionProperties, arguments) -> new MaxAggregator(arguments, TIME))
.put(
new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)),
.put(new FunctionSignature(functionName, Collections.singletonList(TIMESTAMP)),
(functionProperties, arguments) -> new MaxAggregator(arguments, TIMESTAMP))
.build());
.build()
);
}

private static DefaultFunctionResolver varSamp() {
FunctionName functionName = BuiltinFunctionName.VARSAMP.getName();
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> varianceSample(arguments, DOUBLE))
.build());
.build()
);
}

private static DefaultFunctionResolver varPop() {
FunctionName functionName = BuiltinFunctionName.VARPOP.getName();
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> variancePopulation(arguments, DOUBLE))
.build());
.build()
);
}

private static DefaultFunctionResolver stddevSamp() {
FunctionName functionName = BuiltinFunctionName.STDDEV_SAMP.getName();
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> stddevSample(arguments, DOUBLE))
.build());
.build()
);
}

private static DefaultFunctionResolver stddevPop() {
FunctionName functionName = BuiltinFunctionName.STDDEV_POP.getName();
return new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
.put(new FunctionSignature(functionName, Collections.singletonList(DOUBLE)),
(functionProperties, arguments) -> stddevPopulation(arguments, DOUBLE))
.build());
.build()
);
}

private static DefaultFunctionResolver take() {
FunctionName functionName = BuiltinFunctionName.TAKE.getName();
DefaultFunctionResolver functionResolver =
new DefaultFunctionResolver(
functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(
new FunctionSignature(functionName, ImmutableList.of(STRING, INTEGER)),
(functionProperties, arguments) -> new TakeAggregator(arguments, ARRAY))
.build());
DefaultFunctionResolver functionResolver = new DefaultFunctionResolver(functionName,
new ImmutableMap.Builder<FunctionSignature, FunctionBuilder>()
.put(new FunctionSignature(functionName, ImmutableList.of(STRING, INTEGER)),
(functionProperties, arguments) -> new TakeAggregator(arguments, ARRAY))
.build());
return functionResolver;
}

}
Loading

0 comments on commit 8358445

Please sign in to comment.