Skip to content

Commit

Permalink
Clean up and spotlessApply
Browse files Browse the repository at this point in the history
Signed-off-by: acarbonetto <andrewc@bitquilltech.com>
  • Loading branch information
acarbonetto committed Aug 23, 2023
1 parent 0fb46fc commit f008573
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.opensearch.sql.expression.FunctionExpression;
import org.opensearch.sql.expression.env.Environment;

/**
* Nested Function Resolver returns a builder to resolve nested function expressions
*/
/** Nested Function Resolver returns a builder to resolve nested function expressions */
public class NestedFunctionResolver implements FunctionResolver {
@Override
public Pair<FunctionSignature, FunctionBuilder> resolve(FunctionSignature unresolvedSignature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
import org.opensearch.sql.expression.env.Environment;

/**
* OpenSearch functions are FunctionExpression objects used by the core analyzer
* TODO: move to the OpenSearch module as part of the analyzer and optimizer refactor
* OpenSearch functions are FunctionExpression objects used by the core analyzer TODO: move to the
* OpenSearch module as part of the analyzer and optimizer refactor
*/
public class OpenSearchFunction extends FunctionExpression {
private final FunctionName functionName;
private final List<Expression> arguments;

/**
* Determines if SCORE needs to be tracked on the function for relevance-based search
* used by the planner for the OpenSearch request.
* Determines if SCORE needs to be tracked on the function for relevance-based search used by the
* planner for the OpenSearch request.
*/
@Getter @Setter private boolean isScoreTracked;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,12 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.function.Function;
import org.opensearch.sql.data.model.ExprValue;
import org.opensearch.sql.data.type.ExprType;
import org.opensearch.sql.expression.DSL;
import org.opensearch.sql.expression.Expression;
import org.opensearch.sql.expression.FunctionExpression;
import org.opensearch.sql.expression.ReferenceExpression;
import org.opensearch.sql.expression.env.Environment;
import org.opensearch.sql.expression.function.BuiltinFunctionName;
import org.opensearch.sql.expression.function.FunctionProperties;

public class ExpressionTestBase {

protected FunctionProperties functionProperties = new FunctionProperties();

protected Environment<Expression, ExprType> typeEnv;

protected static Environment<Expression, ExprValue> valueEnv() {
return var -> {
if (var instanceof ReferenceExpression) {
Expand Down Expand Up @@ -82,26 +70,4 @@ protected static Environment<Expression, ExprValue> valueEnv() {
}
};
}

protected Environment<Expression, ExprType> typeEnv() {
return typeEnv;
}

protected Function<List<Expression>, FunctionExpression> functionMapping(
BuiltinFunctionName builtinFunctionName) {
switch (builtinFunctionName) {
case ADD:
return (expressions) -> DSL.add(expressions.get(0), expressions.get(1));
case SUBTRACT:
return (expressions) -> DSL.subtract(expressions.get(0), expressions.get(1));
case MULTIPLY:
return (expressions) -> DSL.multiply(expressions.get(0), expressions.get(1));
case DIVIDE:
return (expressions) -> DSL.divide(expressions.get(0), expressions.get(1));
case MODULUS:
return (expressions) -> DSL.modulus(expressions.get(0), expressions.get(1));
default:
throw new RuntimeException();
}
}
}

0 comments on commit f008573

Please sign in to comment.