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

Deprecated Spring IoC and using Guice instead #1177

Merged
merged 4 commits into from
Dec 23, 2022
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
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
spring_version = "5.3.22"
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
version_tokens = opensearch_version.tokenize('-')
Expand Down
3 changes: 0 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ repositories {

dependencies {
api group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
api group: 'org.springframework', name: 'spring-context', version: "${spring_version}"
api group: 'org.springframework', name: 'spring-beans', version: "${spring_version}"
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
api group: 'com.facebook.presto', name: 'presto-matching', version: '0.240'
api group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
Expand All @@ -47,7 +45,6 @@ dependencies {

testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation group: 'org.springframework', name: 'spring-test', version: "${spring_version}"
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.12.4'
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter', version: '3.12.4'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensearch.sql.ast.dsl.AstDSL;
import org.opensearch.sql.ast.expression.Argument;
import org.opensearch.sql.ast.expression.DataType;
Expand All @@ -89,15 +88,7 @@
import org.opensearch.sql.planner.logical.LogicalProject;
import org.opensearch.sql.planner.logical.LogicalRelation;
import org.opensearch.sql.planner.physical.datasource.DataSourceTable;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {AnalyzerTest.class})
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)

class AnalyzerTest extends AnalyzerTestBase {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.google.common.collect.ImmutableSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang3.tuple.Pair;
import org.opensearch.sql.analysis.symbol.Namespace;
Expand All @@ -39,8 +40,6 @@
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.storage.StorageEngine;
import org.opensearch.sql.storage.Table;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;


public class AnalyzerTestBase {
Expand All @@ -49,14 +48,12 @@ protected Map<String, ExprType> typeMapping() {
return TestConfig.typeMapping;
}

@Bean
protected StorageEngine storageEngine() {
return (dataSourceSchemaName, tableName) -> table;
}

@Bean
protected Table table() {
return new Table() {
return Optional.ofNullable(table).orElseGet(() -> new Table() {
@Override
public boolean exists() {
return true;
Expand All @@ -76,31 +73,13 @@ public Map<String, ExprType> getFieldTypes() {
public PhysicalPlan implement(LogicalPlan plan) {
throw new UnsupportedOperationException();
}
};
}

@Bean
protected Table dataSourceTable() {
return new Table() {
@Override
public Map<String, ExprType> getFieldTypes() {
return typeMapping();
}

@Override
public PhysicalPlan implement(LogicalPlan plan) {
throw new UnsupportedOperationException();
}
};
});
}

@Bean
protected DataSourceService dataSourceService() {
return new DefaultDataSourceService();
return Optional.ofNullable(dataSourceService).orElseGet(DefaultDataSourceService::new);
}


@Bean
protected SymbolTable symbolTable() {
SymbolTable symbolTable = new SymbolTable();
typeMapping().entrySet()
Expand All @@ -110,7 +89,6 @@ protected SymbolTable symbolTable() {
return symbolTable;
}

@Bean
protected Environment<Expression, ExprType> typeEnv() {
return var -> {
if (var instanceof ReferenceExpression) {
Expand All @@ -123,25 +101,16 @@ protected Environment<Expression, ExprType> typeEnv() {
};
}

@Autowired
protected AnalysisContext analysisContext;

@Autowired
protected ExpressionAnalyzer expressionAnalyzer;
protected AnalysisContext analysisContext = analysisContext(typeEnvironment(symbolTable()));

@Autowired
protected Analyzer analyzer;
protected ExpressionAnalyzer expressionAnalyzer = expressionAnalyzer();

@Autowired
protected Table table;
protected Table table = table();

@Autowired
protected DataSourceService dataSourceService;
protected DataSourceService dataSourceService = dataSourceService();

@Autowired
protected Environment<Expression, ExprType> typeEnv;
protected Analyzer analyzer = analyzer(expressionAnalyzer(), dataSourceService, table);

@Bean
protected Analyzer analyzer(ExpressionAnalyzer expressionAnalyzer,
DataSourceService dataSourceService,
Table table) {
Expand All @@ -167,17 +136,14 @@ public FunctionName getFunctionName() {
return new Analyzer(expressionAnalyzer, dataSourceService, functionRepository);
}

@Bean
protected TypeEnvironment typeEnvironment(SymbolTable symbolTable) {
return new TypeEnvironment(null, symbolTable);
}

@Bean
protected AnalysisContext analysisContext(TypeEnvironment typeEnvironment) {
return new AnalysisContext(typeEnvironment);
}

@Bean
protected ExpressionAnalyzer expressionAnalyzer() {
return new ExpressionAnalyzer(BuiltinFunctionRepository.getInstance());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensearch.sql.analysis.symbol.Namespace;
import org.opensearch.sql.analysis.symbol.Symbol;
import org.opensearch.sql.ast.dsl.AstDSL;
Expand All @@ -48,15 +47,8 @@
import org.opensearch.sql.expression.DSL;
import org.opensearch.sql.expression.Expression;
import org.opensearch.sql.expression.FunctionExpression;
import org.opensearch.sql.expression.function.FunctionPropertiesTestConfig;
import org.opensearch.sql.expression.window.aggregation.AggregateWindowFunction;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {FunctionPropertiesTestConfig.class, AnalyzerTestBase.class})
class ExpressionAnalyzerTest extends AnalyzerTestBase {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@

import com.google.common.collect.ImmutableList;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensearch.sql.expression.DSL;
import org.opensearch.sql.expression.Expression;
import org.opensearch.sql.expression.function.BuiltinFunctionRepository;
import org.opensearch.sql.expression.window.WindowDefinition;
import org.opensearch.sql.planner.logical.LogicalPlan;
import org.opensearch.sql.planner.logical.LogicalPlanDSL;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {AnalyzerTest.class})
class ExpressionReferenceOptimizerTest extends AnalyzerTestBase {

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensearch.sql.ast.dsl.AstDSL;
import org.opensearch.sql.ast.expression.Alias;
import org.opensearch.sql.ast.expression.HighlightFunction;
import org.opensearch.sql.ast.expression.Literal;
import org.opensearch.sql.expression.NamedExpression;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {AnalyzerTestBase.class})
class NamedExpressionAnalyzerTest extends AnalyzerTestBase {
@Test
void visit_named_select_item() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensearch.sql.analysis.symbol.Namespace;
import org.opensearch.sql.analysis.symbol.Symbol;
import org.opensearch.sql.common.antlr.SyntaxCheckException;
import org.opensearch.sql.data.type.ExprType;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {AnalyzerTestBase.class})
class QualifierAnalyzerTest extends AnalyzerTestBase {

private QualifierAnalyzer qualifierAnalyzer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensearch.sql.ast.dsl.AstDSL;
import org.opensearch.sql.ast.expression.AllFields;
import org.opensearch.sql.data.type.ExprCoreType;
import org.opensearch.sql.data.type.ExprType;
import org.opensearch.sql.expression.DSL;
import org.opensearch.sql.planner.logical.LogicalPlanDSL;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {SelectAnalyzeTest.class})
public class SelectAnalyzeTest extends AnalyzerTestBase {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,8 @@
import org.opensearch.sql.ast.expression.UnresolvedExpression;
import org.opensearch.sql.expression.DSL;
import org.opensearch.sql.expression.NamedExpression;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ExtendWith(MockitoExtension.class)
@ContextConfiguration(classes = {SelectExpressionAnalyzerTest.class})
public class SelectExpressionAnalyzerTest extends AnalyzerTestBase {

@Mock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
import java.util.Collections;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opensearch.sql.ast.dsl.AstDSL;
import org.opensearch.sql.ast.expression.Alias;
import org.opensearch.sql.ast.tree.Sort.SortOption;
Expand All @@ -34,14 +31,7 @@
import org.opensearch.sql.planner.logical.LogicalPlanDSL;
import org.opensearch.sql.planner.logical.LogicalRelation;
import org.opensearch.sql.planner.logical.LogicalSort;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@Configuration
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {SelectExpressionAnalyzerTest.class})
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
class WindowExpressionAnalyzerTest extends AnalyzerTestBase {

private LogicalPlan child;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.storage.StorageEngine;
import org.opensearch.sql.storage.Table;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* Configuration will be used for UT.
*/
@Configuration
public class TestConfig {
public static final String INT_TYPE_NULL_VALUE_FIELD = "int_null_value";
public static final String INT_TYPE_MISSING_VALUE_FIELD = "int_missing_value";
Expand Down Expand Up @@ -59,7 +56,6 @@ public class TestConfig {
.put("timestamp_value", ExprCoreType.TIMESTAMP)
.build();

@Bean
protected StorageEngine storageEngine() {
return new StorageEngine() {
@Override
Expand Down Expand Up @@ -89,8 +85,6 @@ public PhysicalPlan implement(LogicalPlan plan) {
};
}


@Bean
protected SymbolTable symbolTable() {
SymbolTable symbolTable = new SymbolTable();
typeMapping.entrySet()
Expand All @@ -100,7 +94,6 @@ protected SymbolTable symbolTable() {
return symbolTable;
}

@Bean
protected Environment<Expression, ExprType> typeEnv() {
return var -> {
if (var instanceof ReferenceExpression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
import org.opensearch.sql.planner.logical.LogicalPlan;
import org.opensearch.sql.planner.physical.PhysicalPlan;
import org.opensearch.sql.storage.split.Split;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

@ExtendWith(MockitoExtension.class)
class QueryServiceTest {
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

private QueryService queryService;

Expand Down
Loading