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

Decouple function repository and DSL from IoC container for use anywhere #1085

Merged
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.opensearch.sql.ast.expression.AggregateFunction;
import org.opensearch.sql.ast.expression.AllFields;
import org.opensearch.sql.ast.expression.And;
import org.opensearch.sql.ast.expression.Argument;
import org.opensearch.sql.ast.expression.Case;
import org.opensearch.sql.ast.expression.Cast;
import org.opensearch.sql.ast.expression.Compare;
Expand Down Expand Up @@ -74,7 +73,6 @@
public class ExpressionAnalyzer extends AbstractNodeVisitor<Expression, AnalysisContext> {
@Getter
private final BuiltinFunctionRepository repository;
private final DSL dsl;

@Override
public Expression visitCast(Cast node, AnalysisContext context) {
Expand All @@ -86,7 +84,6 @@ public Expression visitCast(Cast node, AnalysisContext context) {
public ExpressionAnalyzer(
BuiltinFunctionRepository repository) {
this.repository = repository;
this.dsl = new DSL(repository);
}

public Expression analyze(UnresolvedExpression unresolved, AnalysisContext context) {
Expand All @@ -103,7 +100,7 @@ public Expression visitEqualTo(EqualTo node, AnalysisContext context) {
Expression left = node.getLeft().accept(this, context);
Expression right = node.getRight().accept(this, context);

return dsl.equal(left, right);
return DSL.equal(left, right);
}

@Override
Expand All @@ -116,36 +113,36 @@ public Expression visitLiteral(Literal node, AnalysisContext context) {
public Expression visitInterval(Interval node, AnalysisContext context) {
Expression value = node.getValue().accept(this, context);
Expression unit = DSL.literal(node.getUnit().name());
return dsl.interval(value, unit);
return DSL.interval(value, unit);
}

@Override
public Expression visitAnd(And node, AnalysisContext context) {
Expression left = node.getLeft().accept(this, context);
Expression right = node.getRight().accept(this, context);

return dsl.and(left, right);
return DSL.and(left, right);
}

@Override
public Expression visitOr(Or node, AnalysisContext context) {
Expression left = node.getLeft().accept(this, context);
Expression right = node.getRight().accept(this, context);

return dsl.or(left, right);
return DSL.or(left, right);
}

@Override
public Expression visitXor(Xor node, AnalysisContext context) {
Expression left = node.getLeft().accept(this, context);
Expression right = node.getRight().accept(this, context);

return dsl.xor(left, right);
return DSL.xor(left, right);
}

@Override
public Expression visitNot(Not node, AnalysisContext context) {
return dsl.not(node.getExpression().accept(this, context));
return DSL.not(node.getExpression().accept(this, context));
}

@Override
Expand Down Expand Up @@ -226,7 +223,7 @@ private Expression visitIn(
if (valueList.size() == 1) {
return visitCompare(new Compare("=", field, valueList.get(0)), context);
} else if (valueList.size() > 1) {
return dsl.or(
return DSL.or(
visitCompare(new Compare("=", field, valueList.get(0)), context),
visitIn(field, valueList.subList(1, valueList.size()), context));
} else {
Expand Down
Loading