From bc2fd586010c0aa9c6e263b7b443b2e17948f047 Mon Sep 17 00:00:00 2001 From: Taylor Curran Date: Fri, 6 Dec 2024 09:58:13 -0800 Subject: [PATCH] Add `final` to constant fields (#3191) Signed-off-by: currantw --- .../sql/spark/dispatcher/model/JobType.java | 2 +- .../spark/execution/session/SessionState.java | 2 +- .../SparkParameterComposerCollection.java | 6 +-- .../parameter/SparkSubmitParameters.java | 2 +- .../sql/spark/utils/SQLQueryUtils.java | 3 +- ...DatasourceEmbeddedQueryIdProviderTest.java | 2 +- .../dispatcher/SparkQueryDispatcherTest.java | 4 +- .../execution/statestore/StateModelTest.java | 2 +- .../SparkParameterComposerCollectionTest.java | 6 +-- .../GrammarElementValidatorProviderTest.java | 8 ++-- .../cluster/ClusterManagerEventListener.java | 14 +++---- .../execution/statestore/StateStore.java | 6 +-- .../job/ScheduledAsyncQueryJobRunner.java | 2 +- ...AsyncQueryExecutorServiceImplSpecTest.java | 2 +- .../AsyncQueryExecutorServiceSpec.java | 2 +- .../AsyncQueryGetResultSpecTest.java | 2 +- ...yncQueryJobMetadataStorageServiceTest.java | 3 +- .../asyncquery/model/MockFlintSparkJob.java | 7 ++-- .../session/InteractiveSessionTest.java | 7 ++-- .../execution/statement/StatementTest.java | 9 +++-- ...IndexStateModelXContentSerializerTest.java | 2 +- .../interceptors/AwsSigningInterceptor.java | 4 +- .../BasicAuthenticationInterceptor.java | 2 +- .../opensearch/sql/common/grok/BasicTest.java | 2 +- ...ataSourceSchemaIdentifierNameResolver.java | 4 +- .../sql/analysis/symbol/SymbolTable.java | 4 +- .../org/opensearch/sql/ast/tree/Filter.java | 2 +- .../org/opensearch/sql/ast/tree/Project.java | 2 +- .../datasource/model/DataSourceMetadata.java | 24 ++++++------ .../datasource/model/DataSourceStatus.java | 2 +- .../sql/datasource/model/DataSourceType.java | 12 +++--- .../streaming/DefaultMetadataLog.java | 2 +- .../predicate/BinaryPredicateOperators.java | 6 +-- .../sql/expression/text/TextFunctions.java | 2 +- .../sql/planner/logical/LogicalNested.java | 2 +- .../sql/planner/physical/NestedOperator.java | 2 +- .../storage/bindingtuple/BindingTuple.java | 2 +- .../opensearch/sql/utils/ExpressionUtils.java | 2 +- .../sql/analysis/AnalyzerTestBase.java | 16 ++++---- .../sql/analysis/TypeEnvironmentTest.java | 2 +- .../org/opensearch/sql/config/TestConfig.java | 2 +- .../sql/data/model/ExprValueUtilsTest.java | 25 ++++++------ .../sql/executor/QueryManagerTest.java | 2 +- .../IntervalTriggerExecutionTest.java | 4 +- .../execution/StreamingQueryPlanTest.java | 2 +- .../sql/expression/ExpressionTestBase.java | 2 +- .../aggregation/AggregationTest.java | 8 ++-- .../function/FunctionSignatureTest.java | 4 +- .../function/WideningTypeRuleTest.java | 2 +- .../BinaryPredicateOperatorTest.java | 2 +- .../planner/physical/PhysicalPlanTest.java | 2 +- .../physical/PhysicalPlanTestBase.java | 2 +- .../datasources/exceptions/ErrorMessage.java | 2 +- .../TransportCreateDataSourceAction.java | 4 +- .../TransportDeleteDataSourceAction.java | 2 +- .../TransportGetDataSourceAction.java | 2 +- .../TransportPatchDataSourceAction.java | 2 +- .../TransportUpdateDataSourceAction.java | 2 +- .../sql/correctness/tests/TestReportTest.java | 2 +- .../sql/correctness/testset/TestQuerySet.java | 2 +- .../sql/legacy/GetEndpointQueryIT.java | 2 +- .../sql/legacy/JoinAliasWriterRuleIT.java | 2 +- .../opensearch/sql/legacy/MultiQueryIT.java | 4 +- .../org/opensearch/sql/legacy/SubqueryIT.java | 2 +- .../sql/ppl/DateTimeComparisonIT.java | 6 +-- .../org/opensearch/sql/ppl/PPLPluginIT.java | 2 +- .../sql/sql/DateTimeComparisonIT.java | 6 +-- .../org/opensearch/sql/sql/ExpressionIT.java | 2 +- .../opensearch/sql/sql/QueryValidationIT.java | 2 +- .../antlr/semantic/scope/SymbolTable.java | 2 +- .../types/function/AggregateFunction.java | 2 +- .../sql/legacy/domain/Condition.java | 14 +++---- .../opensearch/sql/legacy/domain/Having.java | 2 +- .../sql/legacy/domain/IndexStatement.java | 4 +- .../sql/legacy/domain/JoinSelect.java | 4 +- .../opensearch/sql/legacy/domain/KVValue.java | 2 +- .../opensearch/sql/legacy/domain/Order.java | 2 +- .../opensearch/sql/legacy/domain/Paramer.java | 2 +- .../opensearch/sql/legacy/domain/Query.java | 2 +- .../opensearch/sql/legacy/domain/Select.java | 8 ++-- .../opensearch/sql/legacy/domain/Where.java | 2 +- .../legacy/domain/bucketpath/BucketPath.java | 2 +- .../sql/legacy/domain/hints/Hint.java | 4 +- .../executor/GetIndexRequestRestListener.java | 2 +- .../executor/cursor/CursorCloseExecutor.java | 2 +- .../executor/cursor/CursorResultExecutor.java | 4 +- .../sql/legacy/executor/format/DataRows.java | 8 ++-- .../executor/format/DateFieldFormatter.java | 2 +- .../legacy/executor/format/DateFormat.java | 38 +++++++++---------- .../executor/format/DeleteResultSet.java | 4 +- .../executor/format/DescribeResultSet.java | 4 +- .../legacy/executor/format/ErrorMessage.java | 10 ++--- .../sql/legacy/executor/format/Protocol.java | 2 +- .../sql/legacy/executor/format/Schema.java | 6 +-- .../executor/format/SelectResultSet.java | 6 +-- .../legacy/executor/format/ShowResultSet.java | 4 +- .../executor/join/ElasticJoinExecutor.java | 8 ++-- .../join/HashJoinComparisonStructure.java | 4 +- .../join/HashJoinElasticExecutor.java | 6 +-- .../join/NestedLoopsElasticExecutor.java | 4 +- .../executor/multi/ComperableHitResult.java | 6 +-- .../legacy/executor/multi/MinusExecutor.java | 6 +-- .../MinusOneFieldAndOptimizationResult.java | 4 +- .../legacy/executor/multi/UnionExecutor.java | 2 +- .../sql/legacy/metrics/BasicCounter.java | 2 +- .../sql/legacy/metrics/GaugeMetric.java | 2 +- .../opensearch/sql/legacy/metrics/Metric.java | 2 +- .../sql/legacy/metrics/MetricName.java | 4 +- .../sql/legacy/metrics/Metrics.java | 5 ++- .../sql/legacy/metrics/NumericMetric.java | 2 +- .../sql/legacy/parser/CaseWhenParser.java | 6 +-- .../legacy/parser/ElasticSqlExprParser.java | 2 +- .../sql/legacy/parser/FieldMaker.java | 2 +- .../sql/legacy/parser/SqlParser.java | 2 +- .../sql/legacy/parser/SubQueryExpression.java | 2 +- .../sql/legacy/parser/WhereParser.java | 4 +- .../legacy/pit/PointInTimeHandlerImpl.java | 2 +- .../legacy/query/AggregationQueryAction.java | 2 +- .../sql/legacy/query/QueryAction.java | 4 +- ...SqlElasticDeleteByQueryRequestBuilder.java | 2 +- .../query/SqlOpenSearchRequestBuilder.java | 2 +- .../query/join/BackOffRetryStrategy.java | 4 +- .../legacy/query/join/JoinRequestBuilder.java | 4 +- .../query/join/OpenSearchJoinQueryAction.java | 2 +- .../sql/legacy/query/maker/AggMaker.java | 2 +- .../legacy/query/multi/MultiQueryAction.java | 2 +- .../query/multi/MultiQueryRequestBuilder.java | 8 ++-- .../legacy/query/multi/MultiQuerySelect.java | 6 +-- .../converter/SQLAggregationParser.java | 2 +- .../core/BindingTupleQueryPlanner.java | 4 +- .../query/planner/core/ExecuteParams.java | 2 +- .../query/planner/logical/node/Group.java | 4 +- .../physical/estimation/Estimation.java | 2 +- .../physical/node/join/CombinedRow.java | 4 +- .../physical/node/join/JoinAlgorithm.java | 2 +- .../physical/node/join/ListHashTable.java | 2 +- .../legacy/query/planner/resource/Stats.java | 6 +-- .../resource/blocksize/AdaptiveBlockSize.java | 2 +- .../planner/resource/blocksize/BlockSize.java | 2 +- .../request/PreparedStatementRequest.java | 6 +-- .../legacy/rewriter/join/JoinRewriteRule.java | 4 +- .../matchtoterm/TermFieldRewriter.java | 4 +- .../nestedfield/NestedFieldRewriter.java | 2 +- .../legacy/rewriter/nestedfield/Scope.java | 4 +- .../rewriter/ordinal/OrdinalRewriterRule.java | 8 ++-- .../subquery/SubQueryRewriteRule.java | 2 +- .../rewriter/SubqueryAliasRewriter.java | 4 +- .../spatial/BoundingBoxFilterParams.java | 4 +- .../sql/legacy/spatial/CellFilterParams.java | 6 +-- .../legacy/spatial/DistanceFilterParams.java | 4 +- .../opensearch/sql/legacy/spatial/Point.java | 4 +- .../legacy/spatial/PolygonFilterParams.java | 2 +- .../spatial/RangeDistanceFilterParams.java | 2 +- .../legacy/spatial/SpatialParamsFactory.java | 2 +- .../sql/legacy/utils/SQLFunctions.java | 2 +- .../sql/legacy/antlr/SyntaxAnalysisTest.java | 4 +- .../semantic/SemanticAnalyzerConfigTest.java | 2 +- .../semantic/SemanticAnalyzerTestBase.java | 4 +- .../semantic/scope/TypeSupplierTest.java | 2 +- .../visitor/AntlrSqlParseTreeVisitorTest.java | 4 +- .../executor/AsyncRestExecutorTest.java | 2 +- .../pit/PointInTimeHandlerImplTest.java | 2 +- .../unittest/ErrorMessageFactoryTest.java | 4 +- .../legacy/unittest/SqlRequestParamTest.java | 2 +- .../expression/core/BinaryExpressionTest.java | 2 +- .../expression/core/UnaryExpressionTest.java | 2 +- .../expression/model/ExprValueUtilsTest.java | 2 +- .../unittest/parser/BucketPathTest.java | 2 +- .../legacy/unittest/parser/SqlParserTest.java | 2 +- .../unittest/parser/SubQueryParserTest.java | 2 +- .../planner/QueryPlannerBatchTest.java | 18 +++++---- .../planner/QueryPlannerMonitorTest.java | 2 +- .../converter/SQLAggregationParserTest.java | 2 +- .../SQLExprToExpressionConverterTest.java | 2 +- .../identifier/UnquoteIdentifierRuleTest.java | 4 +- .../ordinal/OrdinalRewriterRuleTest.java | 6 +-- .../parent/SQLExprParentSetterRuleTest.java | 2 +- .../subquery/ExistsSubQueryRewriterTest.java | 2 +- .../subquery/InSubqueryRewriterTest.java | 2 +- .../subquery/SubQueryRewriteRuleTest.java | 2 +- .../rewriter/term/TermFieldRewriterTest.java | 2 +- .../unittest/utils/SQLFunctionsTest.java | 2 +- .../util/MultipleIndexClusterUtils.java | 4 +- .../response/error/ErrorMessage.java | 2 +- .../scan/OpenSearchIndexScanQueryBuilder.java | 2 +- .../storage/script/sort/SortQueryBuilder.java | 4 +- .../OpenSearchExprGeoPointValueTest.java | 3 +- .../planner/physical/MLOperatorTest.java | 2 +- .../response/OpenSearchResponseTest.java | 6 +-- .../error/ErrorMessageFactoryTest.java | 4 +- .../TransportPPLQueryRequestTest.java | 2 +- .../sql/ppl/parser/AstExpressionBuilder.java | 2 +- .../opensearch/sql/ppl/PPLServiceTest.java | 4 +- .../sql/ppl/antlr/PPLSyntaxParserTest.java | 2 +- .../sql/ppl/domain/PPLQueryRequestTest.java | 2 +- .../sql/ppl/parser/AstBuilderTest.java | 2 +- .../ppl/parser/AstStatementBuilderTest.java | 2 +- .../protocol/response/QueryResultTest.java | 2 +- .../sql/spark/client/EmrClientImpl.java | 2 +- .../opensearch/sql/sql/SQLServiceTest.java | 4 +- 200 files changed, 393 insertions(+), 383 deletions(-) diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/JobType.java b/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/JobType.java index af1f69d74b..26b391933b 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/JobType.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/dispatcher/model/JobType.java @@ -11,7 +11,7 @@ public enum JobType { REFRESH("refresh"), BATCH("batch"); - private String text; + private final String text; JobType(String text) { this.text = text; diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/execution/session/SessionState.java b/async-query-core/src/main/java/org/opensearch/sql/spark/execution/session/SessionState.java index bd5d14c603..fc15308e05 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/execution/session/SessionState.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/execution/session/SessionState.java @@ -20,7 +20,7 @@ public enum SessionState { DEAD("dead"), FAIL("fail"); - public static List END_STATE = ImmutableList.of(DEAD, FAIL); + public static final List END_STATE = ImmutableList.of(DEAD, FAIL); private final String sessionState; diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollection.java b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollection.java index a6a88738bf..c4d9509bd2 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollection.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollection.java @@ -21,9 +21,9 @@ * be registered during initialization such as in Guice Module. */ public class SparkParameterComposerCollection { - private Collection generalComposers = new ArrayList<>(); - private Map> datasourceComposers = - new HashMap<>(); + private final Collection generalComposers = new ArrayList<>(); + private final Map> + datasourceComposers = new HashMap<>(); /** * Register composers for specific DataSourceType. The registered composer is called only if the diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParameters.java b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParameters.java index 84fd49b712..a496ad7503 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParameters.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/parameter/SparkSubmitParameters.java @@ -17,7 +17,7 @@ public class SparkSubmitParameters { public static final String EQUALS = "="; @Setter private String className = DEFAULT_CLASS_NAME; - private Map config = new LinkedHashMap<>(); + private final Map config = new LinkedHashMap<>(); /** Extra parameters to append finally */ @Setter private String extraParameters; diff --git a/async-query-core/src/main/java/org/opensearch/sql/spark/utils/SQLQueryUtils.java b/async-query-core/src/main/java/org/opensearch/sql/spark/utils/SQLQueryUtils.java index 3ba9c23ed7..bd7060b776 100644 --- a/async-query-core/src/main/java/org/opensearch/sql/spark/utils/SQLQueryUtils.java +++ b/async-query-core/src/main/java/org/opensearch/sql/spark/utils/SQLQueryUtils.java @@ -90,7 +90,8 @@ public static SqlBaseParser getBaseParser(String sqlQuery) { public static class SparkSqlTableNameVisitor extends SqlBaseParserBaseVisitor { - @Getter private List fullyQualifiedTableNames = new LinkedList<>(); + @Getter + private final List fullyQualifiedTableNames = new LinkedList<>(); public SparkSqlTableNameVisitor() {} diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/DatasourceEmbeddedQueryIdProviderTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/DatasourceEmbeddedQueryIdProviderTest.java index 7f1c92dff3..2cd50d755d 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/DatasourceEmbeddedQueryIdProviderTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/DatasourceEmbeddedQueryIdProviderTest.java @@ -19,7 +19,7 @@ class DatasourceEmbeddedQueryIdProviderTest { @Mock AsyncQueryRequestContext asyncQueryRequestContext; - DatasourceEmbeddedQueryIdProvider datasourceEmbeddedQueryIdProvider = + final DatasourceEmbeddedQueryIdProvider datasourceEmbeddedQueryIdProvider = new DatasourceEmbeddedQueryIdProvider(); @Test diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java index 61d72773d9..b5ea349045 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/dispatcher/SparkQueryDispatcherTest.java @@ -129,7 +129,7 @@ public class SparkQueryDispatcherTest { new GrammarElementValidatorProvider( ImmutableMap.of(), new DefaultGrammarElementValidator())); - private DataSourceSparkParameterComposer dataSourceSparkParameterComposer = + private final DataSourceSparkParameterComposer dataSourceSparkParameterComposer = (datasourceMetadata, sparkSubmitParameters, dispatchQueryRequest, context) -> { sparkSubmitParameters.setConfigItem(FLINT_INDEX_STORE_AUTH_KEY, "basic"); sparkSubmitParameters.setConfigItem(FLINT_INDEX_STORE_HOST_KEY, "HOST"); @@ -139,7 +139,7 @@ public class SparkQueryDispatcherTest { KEY_FROM_DATASOURCE_COMPOSER, VALUE_FROM_DATASOURCE_COMPOSER); }; - private GeneralSparkParameterComposer generalSparkParameterComposer = + private final GeneralSparkParameterComposer generalSparkParameterComposer = (sparkSubmitParameters, dispatchQueryRequest, context) -> { sparkSubmitParameters.setConfigItem(KEY_FROM_COMPOSER, VALUE_FROM_COMPOSER); }; diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/execution/statestore/StateModelTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/execution/statestore/StateModelTest.java index 15d1ec2ecc..fdbbbc17e0 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/execution/statestore/StateModelTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/execution/statestore/StateModelTest.java @@ -25,7 +25,7 @@ public String getId() { } } - ConcreteStateModel model = + final ConcreteStateModel model = ConcreteStateModel.builder().metadata(ImmutableMap.of(METADATA_KEY, METADATA_VALUE)).build(); @Test diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollectionTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollectionTest.java index c0c97caa58..8cd1de8b27 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollectionTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/parameter/SparkParameterComposerCollectionTest.java @@ -30,9 +30,9 @@ class SparkParameterComposerCollectionTest { @Mock DispatchQueryRequest dispatchQueryRequest; @Mock AsyncQueryRequestContext asyncQueryRequestContext; - DataSourceType type1 = new DataSourceType("TYPE1"); - DataSourceType type2 = new DataSourceType("TYPE2"); - DataSourceType type3 = new DataSourceType("TYPE3"); + final DataSourceType type1 = new DataSourceType("TYPE1"); + final DataSourceType type2 = new DataSourceType("TYPE2"); + final DataSourceType type3 = new DataSourceType("TYPE3"); SparkParameterComposerCollection collection; diff --git a/async-query-core/src/test/java/org/opensearch/sql/spark/validator/GrammarElementValidatorProviderTest.java b/async-query-core/src/test/java/org/opensearch/sql/spark/validator/GrammarElementValidatorProviderTest.java index 3b24c3c8ab..a42c9f7cd5 100644 --- a/async-query-core/src/test/java/org/opensearch/sql/spark/validator/GrammarElementValidatorProviderTest.java +++ b/async-query-core/src/test/java/org/opensearch/sql/spark/validator/GrammarElementValidatorProviderTest.java @@ -12,13 +12,13 @@ import org.opensearch.sql.datasource.model.DataSourceType; class GrammarElementValidatorProviderTest { - S3GlueSQLGrammarElementValidator s3GlueSQLGrammarElementValidator = + final S3GlueSQLGrammarElementValidator s3GlueSQLGrammarElementValidator = new S3GlueSQLGrammarElementValidator(); - SecurityLakeSQLGrammarElementValidator securityLakeSQLGrammarElementValidator = + final SecurityLakeSQLGrammarElementValidator securityLakeSQLGrammarElementValidator = new SecurityLakeSQLGrammarElementValidator(); - DefaultGrammarElementValidator defaultGrammarElementValidator = + final DefaultGrammarElementValidator defaultGrammarElementValidator = new DefaultGrammarElementValidator(); - GrammarElementValidatorProvider grammarElementValidatorProvider = + final GrammarElementValidatorProvider grammarElementValidatorProvider = new GrammarElementValidatorProvider( ImmutableMap.of( DataSourceType.S3GLUE, s3GlueSQLGrammarElementValidator, diff --git a/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java b/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java index 6c660f073c..52c829318a 100644 --- a/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java +++ b/async-query/src/main/java/org/opensearch/sql/spark/cluster/ClusterManagerEventListener.java @@ -30,13 +30,13 @@ public class ClusterManagerEventListener implements LocalNodeClusterManagerListe private Cancellable flintIndexRetentionCron; private Cancellable flintStreamingJobHouseKeeperCron; - private ClusterService clusterService; - private ThreadPool threadPool; - private Client client; - private Clock clock; - private DataSourceService dataSourceService; - private FlintIndexMetadataService flintIndexMetadataService; - private FlintIndexOpFactory flintIndexOpFactory; + private final ClusterService clusterService; + private final ThreadPool threadPool; + private final Client client; + private final Clock clock; + private final DataSourceService dataSourceService; + private final FlintIndexMetadataService flintIndexMetadataService; + private final FlintIndexOpFactory flintIndexOpFactory; private Duration sessionTtlDuration; private Duration resultTtlDuration; private TimeValue streamingJobHouseKeepingInterval; diff --git a/async-query/src/main/java/org/opensearch/sql/spark/execution/statestore/StateStore.java b/async-query/src/main/java/org/opensearch/sql/spark/execution/statestore/StateStore.java index 18dce7b7b2..552c646cbe 100644 --- a/async-query/src/main/java/org/opensearch/sql/spark/execution/statestore/StateStore.java +++ b/async-query/src/main/java/org/opensearch/sql/spark/execution/statestore/StateStore.java @@ -67,9 +67,9 @@ */ @RequiredArgsConstructor public class StateStore { - public static String SETTINGS_FILE_NAME = "query_execution_request_settings.yml"; - public static String MAPPING_FILE_NAME = "query_execution_request_mapping.yml"; - public static String ALL_DATASOURCE = "*"; + public static final String SETTINGS_FILE_NAME = "query_execution_request_settings.yml"; + public static final String MAPPING_FILE_NAME = "query_execution_request_mapping.yml"; + public static final String ALL_DATASOURCE = "*"; private static final Logger LOG = LogManager.getLogger(); diff --git a/async-query/src/main/java/org/opensearch/sql/spark/scheduler/job/ScheduledAsyncQueryJobRunner.java b/async-query/src/main/java/org/opensearch/sql/spark/scheduler/job/ScheduledAsyncQueryJobRunner.java index 3652acf295..a2abb8e944 100644 --- a/async-query/src/main/java/org/opensearch/sql/spark/scheduler/job/ScheduledAsyncQueryJobRunner.java +++ b/async-query/src/main/java/org/opensearch/sql/spark/scheduler/job/ScheduledAsyncQueryJobRunner.java @@ -40,7 +40,7 @@ public class ScheduledAsyncQueryJobRunner implements ScheduledJobRunner { AsyncRestExecutor.SQL_WORKER_THREAD_POOL_NAME; private static final Logger LOGGER = LogManager.getLogger(ScheduledAsyncQueryJobRunner.class); - private static ScheduledAsyncQueryJobRunner INSTANCE = new ScheduledAsyncQueryJobRunner(); + private static final ScheduledAsyncQueryJobRunner INSTANCE = new ScheduledAsyncQueryJobRunner(); public static ScheduledAsyncQueryJobRunner getJobRunnerInstance() { return INSTANCE; diff --git a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceImplSpecTest.java b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceImplSpecTest.java index 175f9ac914..e6459c752e 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceImplSpecTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceImplSpecTest.java @@ -44,7 +44,7 @@ import org.opensearch.sql.spark.utils.IDUtils; public class AsyncQueryExecutorServiceImplSpecTest extends AsyncQueryExecutorServiceSpec { - AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); + final AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); @Disabled("batch query is unsupported") public void withoutSessionCreateAsyncQueryThenGetResultThenCancel() { diff --git a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java index 53b465aa6d..9511359f86 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryExecutorServiceSpec.java @@ -133,7 +133,7 @@ public class AsyncQueryExecutorServiceSpec extends OpenSearchIntegTestCase { protected StatementStorageService statementStorageService; protected AsyncQueryScheduler asyncQueryScheduler; protected AsyncQueryRequestContext asyncQueryRequestContext; - protected SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider(); + protected final SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider(); @Override protected Collection> nodePlugins() { diff --git a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryGetResultSpecTest.java b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryGetResultSpecTest.java index ef98e955f6..5f6d7190da 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryGetResultSpecTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/AsyncQueryGetResultSpecTest.java @@ -41,7 +41,7 @@ import org.opensearch.sql.spark.transport.model.AsyncQueryResult; public class AsyncQueryGetResultSpecTest extends AsyncQueryExecutorServiceSpec { - AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); + final AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); /** Mock Flint index and index state */ private final FlintDatasetMock mockIndex = diff --git a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/OpenSearchAsyncQueryJobMetadataStorageServiceTest.java b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/OpenSearchAsyncQueryJobMetadataStorageServiceTest.java index c84d68421d..d373f451a6 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/OpenSearchAsyncQueryJobMetadataStorageServiceTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/OpenSearchAsyncQueryJobMetadataStorageServiceTest.java @@ -28,7 +28,8 @@ public class OpenSearchAsyncQueryJobMetadataStorageServiceTest extends OpenSearc private static final String MOCK_RESULT_INDEX = "resultIndex"; private static final String MOCK_QUERY_ID = "00fdo6u94n7abo0q"; private OpenSearchAsyncQueryJobMetadataStorageService openSearchJobMetadataStorageService; - private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); + private final AsyncQueryRequestContext asyncQueryRequestContext = + new NullAsyncQueryRequestContext(); @Before public void setup() { diff --git a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/model/MockFlintSparkJob.java b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/model/MockFlintSparkJob.java index 0dc8f02820..e61d550d68 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/model/MockFlintSparkJob.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/asyncquery/model/MockFlintSparkJob.java @@ -16,9 +16,10 @@ public class MockFlintSparkJob { private FlintIndexStateModel stateModel; - private FlintIndexStateModelService flintIndexStateModelService; - private String datasource; - private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); + private final FlintIndexStateModelService flintIndexStateModelService; + private final String datasource; + private final AsyncQueryRequestContext asyncQueryRequestContext = + new NullAsyncQueryRequestContext(); public MockFlintSparkJob( FlintIndexStateModelService flintIndexStateModelService, String latestId, String datasource) { diff --git a/async-query/src/test/java/org/opensearch/sql/spark/execution/session/InteractiveSessionTest.java b/async-query/src/test/java/org/opensearch/sql/spark/execution/session/InteractiveSessionTest.java index d0bfed94c0..30a71607b0 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/execution/session/InteractiveSessionTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/execution/session/InteractiveSessionTest.java @@ -44,10 +44,11 @@ public class InteractiveSessionTest extends OpenSearchIntegTestCase { private StartJobRequest startJobRequest; private SessionStorageService sessionStorageService; private StatementStorageService statementStorageService; - private SessionConfigSupplier sessionConfigSupplier = () -> 600000L; + private final SessionConfigSupplier sessionConfigSupplier = () -> 600000L; private SessionManager sessionManager; - private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); - private SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider(); + private final AsyncQueryRequestContext asyncQueryRequestContext = + new NullAsyncQueryRequestContext(); + private final SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider(); @Before public void setup() { diff --git a/async-query/src/test/java/org/opensearch/sql/spark/execution/statement/StatementTest.java b/async-query/src/test/java/org/opensearch/sql/spark/execution/statement/StatementTest.java index fe3d5f3177..49a4d69222 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/execution/statement/StatementTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/execution/statement/StatementTest.java @@ -47,12 +47,13 @@ public class StatementTest extends OpenSearchIntegTestCase { private StatementStorageService statementStorageService; private SessionStorageService sessionStorageService; - private TestEMRServerlessClient emrsClient = new TestEMRServerlessClient(); - private SessionConfigSupplier sessionConfigSupplier = () -> 600000L; - private SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider(); + private final TestEMRServerlessClient emrsClient = new TestEMRServerlessClient(); + private final SessionConfigSupplier sessionConfigSupplier = () -> 600000L; + private final SessionIdProvider sessionIdProvider = new DatasourceEmbeddedSessionIdProvider(); private SessionManager sessionManager; - private AsyncQueryRequestContext asyncQueryRequestContext = new NullAsyncQueryRequestContext(); + private final AsyncQueryRequestContext asyncQueryRequestContext = + new NullAsyncQueryRequestContext(); @Before public void setup() { diff --git a/async-query/src/test/java/org/opensearch/sql/spark/execution/xcontent/FlintIndexStateModelXContentSerializerTest.java b/async-query/src/test/java/org/opensearch/sql/spark/execution/xcontent/FlintIndexStateModelXContentSerializerTest.java index 0d6d5f3119..1840c52457 100644 --- a/async-query/src/test/java/org/opensearch/sql/spark/execution/xcontent/FlintIndexStateModelXContentSerializerTest.java +++ b/async-query/src/test/java/org/opensearch/sql/spark/execution/xcontent/FlintIndexStateModelXContentSerializerTest.java @@ -23,7 +23,7 @@ @ExtendWith(MockitoExtension.class) class FlintIndexStateModelXContentSerializerTest { - private FlintIndexStateModelXContentSerializer serializer = + private final FlintIndexStateModelXContentSerializer serializer = new FlintIndexStateModelXContentSerializer(); @Test diff --git a/common/src/main/java/org/opensearch/sql/common/interceptors/AwsSigningInterceptor.java b/common/src/main/java/org/opensearch/sql/common/interceptors/AwsSigningInterceptor.java index 16196544b5..1ab1bb8976 100644 --- a/common/src/main/java/org/opensearch/sql/common/interceptors/AwsSigningInterceptor.java +++ b/common/src/main/java/org/opensearch/sql/common/interceptors/AwsSigningInterceptor.java @@ -24,9 +24,9 @@ public class AwsSigningInterceptor implements Interceptor { - private OkHttpAwsV4Signer okHttpAwsV4Signer; + private final OkHttpAwsV4Signer okHttpAwsV4Signer; - private AWSCredentialsProvider awsCredentialsProvider; + private final AWSCredentialsProvider awsCredentialsProvider; private static final Logger LOG = LogManager.getLogger(); diff --git a/common/src/main/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptor.java b/common/src/main/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptor.java index 15e9a0fc12..0ade25520f 100644 --- a/common/src/main/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptor.java +++ b/common/src/main/java/org/opensearch/sql/common/interceptors/BasicAuthenticationInterceptor.java @@ -16,7 +16,7 @@ public class BasicAuthenticationInterceptor implements Interceptor { - private String credentials; + private final String credentials; public BasicAuthenticationInterceptor(@NonNull String username, @NonNull String password) { this.credentials = Credentials.basic(username, password); diff --git a/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java b/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java index c724b58f3e..748495bff6 100644 --- a/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java +++ b/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java @@ -33,7 +33,7 @@ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class BasicTest { - @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); + @Rule public final TemporaryFolder tempFolder = new TemporaryFolder(); private GrokCompiler compiler; diff --git a/core/src/main/java/org/opensearch/sql/analysis/DataSourceSchemaIdentifierNameResolver.java b/core/src/main/java/org/opensearch/sql/analysis/DataSourceSchemaIdentifierNameResolver.java index 01145dc7df..31719d2fe3 100644 --- a/core/src/main/java/org/opensearch/sql/analysis/DataSourceSchemaIdentifierNameResolver.java +++ b/core/src/main/java/org/opensearch/sql/analysis/DataSourceSchemaIdentifierNameResolver.java @@ -18,8 +18,8 @@ public class DataSourceSchemaIdentifierNameResolver { private String dataSourceName = DEFAULT_DATASOURCE_NAME; private String schemaName = DEFAULT_SCHEMA_NAME; - private String identifierName; - private DataSourceService dataSourceService; + private final String identifierName; + private final DataSourceService dataSourceService; private static final String DOT = "."; diff --git a/core/src/main/java/org/opensearch/sql/analysis/symbol/SymbolTable.java b/core/src/main/java/org/opensearch/sql/analysis/symbol/SymbolTable.java index 8bb6824a63..64a4fc4e09 100644 --- a/core/src/main/java/org/opensearch/sql/analysis/symbol/SymbolTable.java +++ b/core/src/main/java/org/opensearch/sql/analysis/symbol/SymbolTable.java @@ -20,14 +20,14 @@ public class SymbolTable { /** Two-dimension hash table to manage symbols with type in different namespace. */ - private Map> tableByNamespace = + private final Map> tableByNamespace = new EnumMap<>(Namespace.class); /** * Two-dimension hash table to manage symbols with type in different namespace. Comparing with * tableByNamespace, orderedTable use the LinkedHashMap to keep the order of symbol. */ - private Map> orderedTable = + private final Map> orderedTable = new EnumMap<>(Namespace.class); /** diff --git a/core/src/main/java/org/opensearch/sql/ast/tree/Filter.java b/core/src/main/java/org/opensearch/sql/ast/tree/Filter.java index 6c57275db9..da98fef7be 100644 --- a/core/src/main/java/org/opensearch/sql/ast/tree/Filter.java +++ b/core/src/main/java/org/opensearch/sql/ast/tree/Filter.java @@ -18,7 +18,7 @@ @EqualsAndHashCode(callSuper = false) @Getter public class Filter extends UnresolvedPlan { - private UnresolvedExpression condition; + private final UnresolvedExpression condition; private UnresolvedPlan child; public Filter(UnresolvedExpression condition) { diff --git a/core/src/main/java/org/opensearch/sql/ast/tree/Project.java b/core/src/main/java/org/opensearch/sql/ast/tree/Project.java index cffb4dfdce..bbe4d0e2ce 100644 --- a/core/src/main/java/org/opensearch/sql/ast/tree/Project.java +++ b/core/src/main/java/org/opensearch/sql/ast/tree/Project.java @@ -22,7 +22,7 @@ @EqualsAndHashCode(callSuper = false) public class Project extends UnresolvedPlan { @Setter private List projectList; - private List argExprList; + private final List argExprList; private UnresolvedPlan child; public Project(List projectList) { diff --git a/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceMetadata.java b/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceMetadata.java index 6efc7c935c..2282bc694a 100644 --- a/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceMetadata.java +++ b/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceMetadata.java @@ -30,36 +30,36 @@ public class DataSourceMetadata { public static final String DEFAULT_RESULT_INDEX = "query_execution_result"; public static final int MAX_RESULT_INDEX_NAME_SIZE = 255; - private static String DATASOURCE_NAME_REGEX = "[@*A-Za-z]+?[*a-zA-Z_\\-0-9]*"; + private static final String DATASOURCE_NAME_REGEX = "[@*A-Za-z]+?[*a-zA-Z_\\-0-9]*"; // OS doesn’t allow uppercase: https://tinyurl.com/yse2xdbx public static final String RESULT_INDEX_NAME_PATTERN = "[a-z0-9_-]+"; - public static String INVALID_RESULT_INDEX_NAME_SIZE = + public static final String INVALID_RESULT_INDEX_NAME_SIZE = "Result index name size must contains less than " + MAX_RESULT_INDEX_NAME_SIZE + " characters."; - public static String INVALID_CHAR_IN_RESULT_INDEX_NAME = + public static final String INVALID_CHAR_IN_RESULT_INDEX_NAME = "Result index name has invalid character. Valid characters are a-z, 0-9, -(hyphen) and" + " _(underscore)."; - public static String INVALID_RESULT_INDEX_PREFIX = + public static final String INVALID_RESULT_INDEX_PREFIX = "Result index must start with " + DEFAULT_RESULT_INDEX; - @JsonProperty private String name; + @JsonProperty private final String name; - @JsonProperty private String description; + @JsonProperty private final String description; @JsonProperty @JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) - private DataSourceType connector; + private final DataSourceType connector; - @JsonProperty private List allowedRoles; + @JsonProperty private final List allowedRoles; - @JsonProperty private Map properties; + @JsonProperty private final Map properties; - @JsonProperty private String resultIndex; + @JsonProperty private final String resultIndex; - @JsonProperty private DataSourceStatus status; + @JsonProperty private final DataSourceStatus status; - public static Function DATASOURCE_TO_RESULT_INDEX = + public static final Function DATASOURCE_TO_RESULT_INDEX = datasourceName -> String.format("%s_%s", DEFAULT_RESULT_INDEX, datasourceName); private DataSourceMetadata(Builder builder) { diff --git a/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceStatus.java b/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceStatus.java index bca47217c1..a4282eb419 100644 --- a/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceStatus.java +++ b/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceStatus.java @@ -10,7 +10,7 @@ public enum DataSourceStatus { ACTIVE("active"), DISABLED("disabled"); - private String text; + private final String text; DataSourceStatus(String text) { this.text = text; diff --git a/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceType.java b/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceType.java index ac8ae1a5e1..442497094b 100644 --- a/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceType.java +++ b/core/src/main/java/org/opensearch/sql/datasource/model/DataSourceType.java @@ -13,14 +13,14 @@ @RequiredArgsConstructor @EqualsAndHashCode public class DataSourceType { - public static DataSourceType PROMETHEUS = new DataSourceType("PROMETHEUS"); - public static DataSourceType OPENSEARCH = new DataSourceType("OPENSEARCH"); - public static DataSourceType SPARK = new DataSourceType("SPARK"); - public static DataSourceType S3GLUE = new DataSourceType("S3GLUE"); - public static DataSourceType SECURITY_LAKE = new DataSourceType("SECURITY_LAKE"); + public static final DataSourceType PROMETHEUS = new DataSourceType("PROMETHEUS"); + public static final DataSourceType OPENSEARCH = new DataSourceType("OPENSEARCH"); + public static final DataSourceType SPARK = new DataSourceType("SPARK"); + public static final DataSourceType S3GLUE = new DataSourceType("S3GLUE"); + public static final DataSourceType SECURITY_LAKE = new DataSourceType("SECURITY_LAKE"); // Map from uppercase DataSourceType name to DataSourceType object - private static Map knownValues = new HashMap<>(); + private static final Map knownValues = new HashMap<>(); static { register(PROMETHEUS, OPENSEARCH, SPARK, S3GLUE, SECURITY_LAKE); diff --git a/core/src/main/java/org/opensearch/sql/executor/streaming/DefaultMetadataLog.java b/core/src/main/java/org/opensearch/sql/executor/streaming/DefaultMetadataLog.java index e439d93f6c..48975a5608 100644 --- a/core/src/main/java/org/opensearch/sql/executor/streaming/DefaultMetadataLog.java +++ b/core/src/main/java/org/opensearch/sql/executor/streaming/DefaultMetadataLog.java @@ -26,7 +26,7 @@ public class DefaultMetadataLog implements MetadataLog { private static final long MIN_ACCEPTABLE_ID = 0L; - private SortedMap metadataMap = new TreeMap<>(); + private final SortedMap metadataMap = new TreeMap<>(); @Override public boolean add(Long batchId, T metadata) { diff --git a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperators.java b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperators.java index 96ff7785b7..6adc4fb2a3 100644 --- a/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperators.java +++ b/core/src/main/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperators.java @@ -118,7 +118,7 @@ public static void register(BuiltinFunctionRepository repository) { * * */ - private static Table andTable = + private static final Table andTable = new ImmutableTable.Builder() .put(LITERAL_TRUE, LITERAL_TRUE, LITERAL_TRUE) .put(LITERAL_TRUE, LITERAL_FALSE, LITERAL_FALSE) @@ -193,7 +193,7 @@ public static void register(BuiltinFunctionRepository repository) { * * */ - private static Table orTable = + private static final Table orTable = new ImmutableTable.Builder() .put(LITERAL_TRUE, LITERAL_TRUE, LITERAL_TRUE) .put(LITERAL_TRUE, LITERAL_FALSE, LITERAL_TRUE) @@ -268,7 +268,7 @@ public static void register(BuiltinFunctionRepository repository) { * * */ - private static Table xorTable = + private static final Table xorTable = new ImmutableTable.Builder() .put(LITERAL_TRUE, LITERAL_TRUE, LITERAL_FALSE) .put(LITERAL_TRUE, LITERAL_FALSE, LITERAL_TRUE) diff --git a/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java b/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java index 8a5302070c..2c3bbf7efb 100644 --- a/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java +++ b/core/src/main/java/org/opensearch/sql/expression/text/TextFunctions.java @@ -39,7 +39,7 @@ */ @UtilityClass public class TextFunctions { - private static String EMPTY_STRING = ""; + private static final String EMPTY_STRING = ""; /** * Register String Functions. diff --git a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java index e791a1fad1..089efe707e 100644 --- a/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java +++ b/core/src/main/java/org/opensearch/sql/planner/logical/LogicalNested.java @@ -19,7 +19,7 @@ @Getter @ToString public class LogicalNested extends LogicalPlan { - private List> fields; + private final List> fields; private final List projectList; /** Constructor of LogicalNested. */ diff --git a/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java b/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java index 8539df5463..fb5ec276ac 100644 --- a/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java +++ b/core/src/main/java/org/opensearch/sql/planner/physical/NestedOperator.java @@ -37,7 +37,7 @@ public class NestedOperator extends PhysicalPlan { @Getter private final Set fields; // Needs to be a Set to match legacy implementation @Getter private final Map> groupedPathsAndFields; @EqualsAndHashCode.Exclude private List> result = new ArrayList<>(); - @EqualsAndHashCode.Exclude private List nonNestedFields = new ArrayList<>(); + @EqualsAndHashCode.Exclude private final List nonNestedFields = new ArrayList<>(); @EqualsAndHashCode.Exclude private ListIterator> flattenedResult = result.listIterator(); diff --git a/core/src/main/java/org/opensearch/sql/storage/bindingtuple/BindingTuple.java b/core/src/main/java/org/opensearch/sql/storage/bindingtuple/BindingTuple.java index 2487c651ad..c5c12584fd 100644 --- a/core/src/main/java/org/opensearch/sql/storage/bindingtuple/BindingTuple.java +++ b/core/src/main/java/org/opensearch/sql/storage/bindingtuple/BindingTuple.java @@ -17,7 +17,7 @@ * output column name is bindingName, the value is the ExprValue. */ public abstract class BindingTuple implements Environment { - public static BindingTuple EMPTY = + public static final BindingTuple EMPTY = new BindingTuple() { @Override public ExprValue resolve(ReferenceExpression ref) { diff --git a/core/src/main/java/org/opensearch/sql/utils/ExpressionUtils.java b/core/src/main/java/org/opensearch/sql/utils/ExpressionUtils.java index f04bf3748f..8ae0c6ba88 100644 --- a/core/src/main/java/org/opensearch/sql/utils/ExpressionUtils.java +++ b/core/src/main/java/org/opensearch/sql/utils/ExpressionUtils.java @@ -14,7 +14,7 @@ @UtilityClass public class ExpressionUtils { - public static String PATH_SEP = "."; + public static final String PATH_SEP = "."; /** Format the list of {@link Expression}. */ public static String format(List expressionList) { diff --git a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java index 0bf959a1b7..17f86cadba 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java +++ b/core/src/test/java/org/opensearch/sql/analysis/AnalyzerTestBase.java @@ -148,15 +148,15 @@ protected Environment typeEnv() { }; } - protected AnalysisContext analysisContext = analysisContext(typeEnvironment(symbolTable())); + protected final AnalysisContext analysisContext = analysisContext(typeEnvironment(symbolTable())); - protected ExpressionAnalyzer expressionAnalyzer = expressionAnalyzer(); + protected final ExpressionAnalyzer expressionAnalyzer = expressionAnalyzer(); - protected Table table = table(); + protected final Table table = table(); - protected DataSourceService dataSourceService = dataSourceService(); + protected final DataSourceService dataSourceService = dataSourceService(); - protected Analyzer analyzer = analyzer(expressionAnalyzer(), dataSourceService); + protected final Analyzer analyzer = analyzer(expressionAnalyzer(), dataSourceService); protected Analyzer analyzer( ExpressionAnalyzer expressionAnalyzer, DataSourceService dataSourceService) { @@ -245,11 +245,11 @@ public DataSourceMetadata verifyDataSourceAccessAndGetRawMetadata( private class TestTableFunctionImplementation implements TableFunctionImplementation { - private FunctionName functionName; + private final FunctionName functionName; - private List arguments; + private final List arguments; - private Table table; + private final Table table; public TestTableFunctionImplementation( FunctionName functionName, List arguments, Table table) { diff --git a/core/src/test/java/org/opensearch/sql/analysis/TypeEnvironmentTest.java b/core/src/test/java/org/opensearch/sql/analysis/TypeEnvironmentTest.java index 91677a901e..00e2f10469 100644 --- a/core/src/test/java/org/opensearch/sql/analysis/TypeEnvironmentTest.java +++ b/core/src/test/java/org/opensearch/sql/analysis/TypeEnvironmentTest.java @@ -21,7 +21,7 @@ public class TypeEnvironmentTest { /** Use context class for push/pop. */ - private AnalysisContext context = new AnalysisContext(); + private final AnalysisContext context = new AnalysisContext(); @Test public void defineFieldSymbolInDifferentEnvironmentsShouldBeAbleToResolve() { diff --git a/core/src/test/java/org/opensearch/sql/config/TestConfig.java b/core/src/test/java/org/opensearch/sql/config/TestConfig.java index 92b6aac64f..6655640e28 100644 --- a/core/src/test/java/org/opensearch/sql/config/TestConfig.java +++ b/core/src/test/java/org/opensearch/sql/config/TestConfig.java @@ -33,7 +33,7 @@ public class TestConfig { public static final String STRING_TYPE_NULL_VALUE_FIELD = "string_null_value"; public static final String STRING_TYPE_MISSING_VALUE_FIELD = "string_missing_value"; - public static Map typeMapping = + public static final Map typeMapping = new ImmutableMap.Builder() .put("integer_value", ExprCoreType.INTEGER) .put(INT_TYPE_NULL_VALUE_FIELD, ExprCoreType.INTEGER) diff --git a/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java b/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java index 0baf5052e4..9fe6347102 100644 --- a/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java +++ b/core/src/test/java/org/opensearch/sql/data/model/ExprValueUtilsTest.java @@ -50,18 +50,18 @@ @DisplayName("Test Expression Value Utils") public class ExprValueUtilsTest { - private static LinkedHashMap testTuple = new LinkedHashMap<>(); + private static final LinkedHashMap testTuple = new LinkedHashMap<>(); static { testTuple.put("1", new ExprIntegerValue(1)); } - private static List numberValues = + private static final List numberValues = Stream.of((byte) 1, (short) 1, 1, 1L, 1f, 1D) .map(ExprValueUtils::fromObjectValue) .collect(Collectors.toList()); - private static List nonNumberValues = + private static final List nonNumberValues = Arrays.asList( new ExprStringValue("1"), ExprBooleanValue.of(true), @@ -72,10 +72,10 @@ public class ExprValueUtilsTest { new ExprTimestampValue("2012-08-07 18:00:00"), new ExprIntervalValue(Duration.ofSeconds(100))); - private static List allValues = + private static final List allValues = Lists.newArrayList(Iterables.concat(numberValues, nonNumberValues)); - private static List> numberValueExtractor = + private static final List> numberValueExtractor = Arrays.asList( ExprValueUtils::getByteValue, ExprValueUtils::getShortValue, @@ -83,24 +83,24 @@ public class ExprValueUtilsTest { ExprValueUtils::getLongValue, ExprValueUtils::getFloatValue, ExprValueUtils::getDoubleValue); - private static List> nonNumberValueExtractor = + private static final List> nonNumberValueExtractor = Arrays.asList( ExprValueUtils::getStringValue, ExprValueUtils::getBooleanValue, ExprValueUtils::getCollectionValue, ExprValueUtils::getTupleValue); - private static List> dateAndTimeValueExtractor = + private static final List> dateAndTimeValueExtractor = Arrays.asList( ExprValue::dateValue, ExprValue::timeValue, ExprValue::timestampValue, ExprValue::intervalValue); - private static List> allValueExtractor = + private static final List> allValueExtractor = Lists.newArrayList( Iterables.concat( numberValueExtractor, nonNumberValueExtractor, dateAndTimeValueExtractor)); - private static List numberTypes = + private static final List numberTypes = Arrays.asList( ExprCoreType.BYTE, ExprCoreType.SHORT, @@ -108,10 +108,11 @@ public class ExprValueUtilsTest { ExprCoreType.LONG, ExprCoreType.FLOAT, ExprCoreType.DOUBLE); - private static List nonNumberTypes = Arrays.asList(STRING, BOOLEAN, ARRAY, STRUCT); - private static List dateAndTimeTypes = + private static final List nonNumberTypes = + Arrays.asList(STRING, BOOLEAN, ARRAY, STRUCT); + private static final List dateAndTimeTypes = Arrays.asList(DATE, TIME, TIMESTAMP, INTERVAL); - private static List allTypes = + private static final List allTypes = Lists.newArrayList(Iterables.concat(numberTypes, nonNumberTypes, dateAndTimeTypes)); private static Stream getValueTestArgumentStream() { diff --git a/core/src/test/java/org/opensearch/sql/executor/QueryManagerTest.java b/core/src/test/java/org/opensearch/sql/executor/QueryManagerTest.java index 7f34d348bc..2d8d4d4ee2 100644 --- a/core/src/test/java/org/opensearch/sql/executor/QueryManagerTest.java +++ b/core/src/test/java/org/opensearch/sql/executor/QueryManagerTest.java @@ -17,7 +17,7 @@ class QueryManagerTest { @Mock private QueryId queryId; - private QueryManager queryManager = + private final QueryManager queryManager = id -> { throw new UnsupportedOperationException(); }; diff --git a/core/src/test/java/org/opensearch/sql/executor/execution/IntervalTriggerExecutionTest.java b/core/src/test/java/org/opensearch/sql/executor/execution/IntervalTriggerExecutionTest.java index 9eb99d37e3..030114749c 100644 --- a/core/src/test/java/org/opensearch/sql/executor/execution/IntervalTriggerExecutionTest.java +++ b/core/src/test/java/org/opensearch/sql/executor/execution/IntervalTriggerExecutionTest.java @@ -32,7 +32,7 @@ Helper triggerTask(long interval) { class Helper implements Runnable { - private StreamingQueryPlan.IntervalTriggerExecution executionStrategy; + private final StreamingQueryPlan.IntervalTriggerExecution executionStrategy; private static final int START = 0; @@ -42,7 +42,7 @@ class Helper implements Runnable { private int state = START; - private long interval; + private final long interval; private long taskExecutionTime; diff --git a/core/src/test/java/org/opensearch/sql/executor/execution/StreamingQueryPlanTest.java b/core/src/test/java/org/opensearch/sql/executor/execution/StreamingQueryPlanTest.java index 2e8666aea4..c2cc606a88 100644 --- a/core/src/test/java/org/opensearch/sql/executor/execution/StreamingQueryPlanTest.java +++ b/core/src/test/java/org/opensearch/sql/executor/execution/StreamingQueryPlanTest.java @@ -77,7 +77,7 @@ Helper streamingQuery() { class Helper { - private StreamingQueryPlan queryPlan; + private final StreamingQueryPlan queryPlan; public Helper() { queryPlan = diff --git a/core/src/test/java/org/opensearch/sql/expression/ExpressionTestBase.java b/core/src/test/java/org/opensearch/sql/expression/ExpressionTestBase.java index fd886cdda3..fc7e73d5b2 100644 --- a/core/src/test/java/org/opensearch/sql/expression/ExpressionTestBase.java +++ b/core/src/test/java/org/opensearch/sql/expression/ExpressionTestBase.java @@ -36,7 +36,7 @@ public class ExpressionTestBase { - protected FunctionProperties functionProperties = new FunctionProperties(); + protected final FunctionProperties functionProperties = new FunctionProperties(); protected Environment typeEnv; diff --git a/core/src/test/java/org/opensearch/sql/expression/aggregation/AggregationTest.java b/core/src/test/java/org/opensearch/sql/expression/aggregation/AggregationTest.java index f1a3a9d948..38aa263ddc 100644 --- a/core/src/test/java/org/opensearch/sql/expression/aggregation/AggregationTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/aggregation/AggregationTest.java @@ -17,7 +17,7 @@ public class AggregationTest extends ExpressionTestBase { - protected static List tuples = + protected static final List tuples = Arrays.asList( ExprValueUtils.tupleValue( new ImmutableMap.Builder() @@ -95,7 +95,7 @@ public class AggregationTest extends ExpressionTestBase { "timestamp_value", "2040-01-01 07:00:00"))); - protected static List tuples_with_duplicates = + protected static final List tuples_with_duplicates = Arrays.asList( ExprValueUtils.tupleValue( ImmutableMap.of( @@ -138,7 +138,7 @@ public class AggregationTest extends ExpressionTestBase { "array_value", ImmutableList.of(1, 2)))); - protected static List tuples_with_null_and_missing = + protected static final List tuples_with_null_and_missing = Arrays.asList( ExprValueUtils.tupleValue( ImmutableMap.of("integer_value", 2, "string_value", "m", "double_value", 3d)), @@ -146,7 +146,7 @@ public class AggregationTest extends ExpressionTestBase { ImmutableMap.of("integer_value", 1, "string_value", "f", "double_value", 4d)), ExprValueUtils.tupleValue(Collections.singletonMap("double_value", null))); - protected static List tuples_with_all_null_or_missing = + protected static final List tuples_with_all_null_or_missing = Arrays.asList( ExprValueUtils.tupleValue(Collections.singletonMap("integer_value", null)), ExprValueUtils.tupleValue(Collections.singletonMap("double", null)), diff --git a/core/src/test/java/org/opensearch/sql/expression/function/FunctionSignatureTest.java b/core/src/test/java/org/opensearch/sql/expression/function/FunctionSignatureTest.java index 2fb5dc468e..b301cf7ba8 100644 --- a/core/src/test/java/org/opensearch/sql/expression/function/FunctionSignatureTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/function/FunctionSignatureTest.java @@ -27,8 +27,8 @@ class FunctionSignatureTest { @Mock private FunctionSignature funcSignature; @Mock private List funcParamTypeList; - private FunctionName unresolvedFuncName = FunctionName.of("add"); - private List unresolvedParamTypeList = + private final FunctionName unresolvedFuncName = FunctionName.of("add"); + private final List unresolvedParamTypeList = Arrays.asList(ExprCoreType.INTEGER, ExprCoreType.FLOAT); @Test diff --git a/core/src/test/java/org/opensearch/sql/expression/function/WideningTypeRuleTest.java b/core/src/test/java/org/opensearch/sql/expression/function/WideningTypeRuleTest.java index 9de1e65108..3064ffcdee 100644 --- a/core/src/test/java/org/opensearch/sql/expression/function/WideningTypeRuleTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/function/WideningTypeRuleTest.java @@ -36,7 +36,7 @@ import org.opensearch.sql.exception.ExpressionEvaluationException; class WideningTypeRuleTest { - private static Table numberWidenRule = + private static final Table numberWidenRule = new ImmutableTable.Builder() .put(BYTE, SHORT, 1) .put(BYTE, INTEGER, 2) diff --git a/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java b/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java index 19cbb4674e..3fc7f737f8 100644 --- a/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/expression/operator/predicate/BinaryPredicateOperatorTest.java @@ -57,7 +57,7 @@ class BinaryPredicateOperatorTest extends ExpressionTestBase { - private static List STRING_PATTERN_PAIRS = + private static final List STRING_PATTERN_PAIRS = ImmutableList.of( new StringPatternPair("Michael!", ".*"), new StringPatternPair("new*\\n*line", "new\\\\*.\\\\*line"), diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java index d63ab35773..eb35c00d9e 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTest.java @@ -24,7 +24,7 @@ class PhysicalPlanTest { @Mock PhysicalPlan child; - private PhysicalPlan testPlan = + private final PhysicalPlan testPlan = new PhysicalPlan() { @Override public R accept(PhysicalPlanNodeVisitor visitor, C context) { diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTestBase.java b/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTestBase.java index 6399f945ed..397f241484 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTestBase.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/PhysicalPlanTestBase.java @@ -93,7 +93,7 @@ public class PhysicalPlanTestBase { ImmutableMap.of("ip", "74.125.19.106", "action", "POST", "response", 500))) .build(); - private static Map typeMapping = + private static final Map typeMapping = new ImmutableMap.Builder() .put("ip", ExprCoreType.STRING) .put("action", ExprCoreType.STRING) diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/exceptions/ErrorMessage.java b/datasources/src/main/java/org/opensearch/sql/datasources/exceptions/ErrorMessage.java index a0c0f5e24d..d4c74c7b30 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/exceptions/ErrorMessage.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/exceptions/ErrorMessage.java @@ -14,7 +14,7 @@ /** Error Message. */ public class ErrorMessage { - protected Throwable exception; + protected final Throwable exception; private final int status; diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java index 95e6493e05..edf4d14e1e 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportCreateDataSourceAction.java @@ -30,8 +30,8 @@ public class TransportCreateDataSourceAction public static final ActionType ACTION_TYPE = new ActionType<>(NAME, CreateDataSourceActionResponse::new); - private DataSourceService dataSourceService; - private org.opensearch.sql.opensearch.setting.OpenSearchSettings settings; + private final DataSourceService dataSourceService; + private final org.opensearch.sql.opensearch.setting.OpenSearchSettings settings; /** * TransportCreateDataSourceAction action for creating datasource. diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java index 5578d40651..d17deb7df0 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportDeleteDataSourceAction.java @@ -26,7 +26,7 @@ public class TransportDeleteDataSourceAction public static final ActionType ACTION_TYPE = new ActionType<>(NAME, DeleteDataSourceActionResponse::new); - private DataSourceService dataSourceService; + private final DataSourceService dataSourceService; /** * TransportDeleteDataSourceAction action for deleting datasource. diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java index 34ad59c80f..e2da2a8e0c 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportGetDataSourceAction.java @@ -29,7 +29,7 @@ public class TransportGetDataSourceAction public static final ActionType ACTION_TYPE = new ActionType<>(NAME, GetDataSourceActionResponse::new); - private DataSourceService dataSourceService; + private final DataSourceService dataSourceService; /** * TransportGetDataSourceAction action for getting datasource. diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportPatchDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportPatchDataSourceAction.java index 303e905cec..dd55869df7 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportPatchDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportPatchDataSourceAction.java @@ -30,7 +30,7 @@ public class TransportPatchDataSourceAction public static final ActionType ACTION_TYPE = new ActionType<>(NAME, PatchDataSourceActionResponse::new); - private DataSourceService dataSourceService; + private final DataSourceService dataSourceService; /** * TransportPatchDataSourceAction action for updating datasource. diff --git a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java index fefd0f3a01..44e0625cf7 100644 --- a/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java +++ b/datasources/src/main/java/org/opensearch/sql/datasources/transport/TransportUpdateDataSourceAction.java @@ -29,7 +29,7 @@ public class TransportUpdateDataSourceAction public static final ActionType ACTION_TYPE = new ActionType<>(NAME, UpdateDataSourceActionResponse::new); - private DataSourceService dataSourceService; + private final DataSourceService dataSourceService; /** * TransportUpdateDataSourceAction action for updating datasource. diff --git a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java index 9ac5151b21..43f678f60e 100644 --- a/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java +++ b/integ-test/src/test/java/org/opensearch/sql/correctness/tests/TestReportTest.java @@ -22,7 +22,7 @@ /** Test for {@link TestReport} */ public class TestReportTest { - private TestReport report = new TestReport(); + private final TestReport report = new TestReport(); @Test public void testSuccessReport() { diff --git a/integ-test/src/test/java/org/opensearch/sql/correctness/testset/TestQuerySet.java b/integ-test/src/test/java/org/opensearch/sql/correctness/testset/TestQuerySet.java index 161d314c1d..b3dfbec259 100644 --- a/integ-test/src/test/java/org/opensearch/sql/correctness/testset/TestQuerySet.java +++ b/integ-test/src/test/java/org/opensearch/sql/correctness/testset/TestQuerySet.java @@ -14,7 +14,7 @@ /** Test query set including SQL queries for comparison testing. */ public class TestQuerySet implements Iterable { - private List queries; + private final List queries; /** * Construct by a test query file. diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/GetEndpointQueryIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/GetEndpointQueryIT.java index 81edb54556..6cc4aba811 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/GetEndpointQueryIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/GetEndpointQueryIT.java @@ -16,7 +16,7 @@ /** Tests to cover requests with "?format=csv" parameter */ public class GetEndpointQueryIT extends SQLIntegTestCase { - @Rule public ExpectedException rule = ExpectedException.none(); + @Rule public final ExpectedException rule = ExpectedException.none(); @Override protected void init() throws Exception { diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/JoinAliasWriterRuleIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/JoinAliasWriterRuleIT.java index 75b2b45df6..3933338f0a 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/JoinAliasWriterRuleIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/JoinAliasWriterRuleIT.java @@ -17,7 +17,7 @@ /** Test cases for writing missing join table aliases. */ public class JoinAliasWriterRuleIT extends SQLIntegTestCase { - @Rule public ExpectedException exception = ExpectedException.none(); + @Rule public final ExpectedException exception = ExpectedException.none(); protected void init() throws Exception { loadIndex(Index.ORDER); // opensearch-sql_test_index_order diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/MultiQueryIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/MultiQueryIT.java index 84750f8a27..bee85ac314 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/MultiQueryIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/MultiQueryIT.java @@ -18,9 +18,9 @@ public class MultiQueryIT extends SQLIntegTestCase { - private static String MINUS_SCROLL_DEFAULT_HINT = + private static final String MINUS_SCROLL_DEFAULT_HINT = " /*! MINUS_SCROLL_FETCH_AND_RESULT_LIMITS(1000, 50, 100) */ "; - private static String MINUS_TERMS_OPTIMIZATION_HINT = + private static final String MINUS_TERMS_OPTIMIZATION_HINT = " /*! MINUS_USE_TERMS_OPTIMIZATION(true) */ "; @Override diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java index c1d656628f..39abad92df 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java @@ -37,7 +37,7 @@ public class SubqueryIT extends SQLIntegTestCase { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Override protected void init() throws Exception { diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonIT.java index 7cc083cbb6..dca33b9f96 100644 --- a/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/DateTimeComparisonIT.java @@ -43,9 +43,9 @@ public void resetTimeZone() { TimeZone.setDefault(testTz); } - private String functionCall; - private String name; - private Boolean expectedResult; + private final String functionCall; + private final String name; + private final Boolean expectedResult; public DateTimeComparisonIT( @Name("functionCall") String functionCall, diff --git a/integ-test/src/test/java/org/opensearch/sql/ppl/PPLPluginIT.java b/integ-test/src/test/java/org/opensearch/sql/ppl/PPLPluginIT.java index 44f79a8944..96362a2fd2 100644 --- a/integ-test/src/test/java/org/opensearch/sql/ppl/PPLPluginIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/ppl/PPLPluginIT.java @@ -27,7 +27,7 @@ import org.opensearch.sql.util.TestUtils; public class PPLPluginIT extends PPLIntegTestCase { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); private static final String PERSISTENT = "persistent"; diff --git a/integ-test/src/test/java/org/opensearch/sql/sql/DateTimeComparisonIT.java b/integ-test/src/test/java/org/opensearch/sql/sql/DateTimeComparisonIT.java index af3d81e374..d385b54dff 100644 --- a/integ-test/src/test/java/org/opensearch/sql/sql/DateTimeComparisonIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/sql/DateTimeComparisonIT.java @@ -50,9 +50,9 @@ public void resetTimeZone() { TimeZone.setDefault(testTz); } - private String functionCall; - private String name; - private Boolean expectedResult; + private final String functionCall; + private final String name; + private final Boolean expectedResult; public DateTimeComparisonIT( @Name("functionCall") String functionCall, diff --git a/integ-test/src/test/java/org/opensearch/sql/sql/ExpressionIT.java b/integ-test/src/test/java/org/opensearch/sql/sql/ExpressionIT.java index be1471641e..45da456553 100644 --- a/integ-test/src/test/java/org/opensearch/sql/sql/ExpressionIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/sql/ExpressionIT.java @@ -29,7 +29,7 @@ @Ignore public class ExpressionIT extends RestIntegTestCase { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Override protected void init() throws Exception { diff --git a/integ-test/src/test/java/org/opensearch/sql/sql/QueryValidationIT.java b/integ-test/src/test/java/org/opensearch/sql/sql/QueryValidationIT.java index e42b68631f..8e38af2a92 100644 --- a/integ-test/src/test/java/org/opensearch/sql/sql/QueryValidationIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/sql/QueryValidationIT.java @@ -29,7 +29,7 @@ */ public class QueryValidationIT extends SQLIntegTestCase { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Override protected void init() throws Exception { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/scope/SymbolTable.java b/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/scope/SymbolTable.java index ee9f4545a6..0f65ee1b99 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/scope/SymbolTable.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/scope/SymbolTable.java @@ -20,7 +20,7 @@ public class SymbolTable { /** Two-dimension hash table to manage symbols with type in different namespace */ - private Map> tableByNamespace = + private final Map> tableByNamespace = new EnumMap<>(Namespace.class); /** diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/types/function/AggregateFunction.java b/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/types/function/AggregateFunction.java index 9cebf3dda6..5ede1aa1a5 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/types/function/AggregateFunction.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/antlr/semantic/types/function/AggregateFunction.java @@ -24,7 +24,7 @@ public enum AggregateFunction implements TypeExpression { AVG(func(T(NUMBER)).to(DOUBLE)), SUM(func(T(NUMBER)).to(T)); - private TypeExpressionSpec[] specifications; + private final TypeExpressionSpec[] specifications; AggregateFunction(TypeExpressionSpec... specifications) { this.specifications = specifications; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java index f86635910a..2c86ff00ad 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java @@ -52,15 +52,15 @@ public enum OPERATOR { NTERM, NREGEXP; - public static Map methodNameToOpear; + public static final Map methodNameToOpear; - public static Map operStringToOpear; + public static final Map operStringToOpear; - public static Map simpleOperStringToOpear; + public static final Map simpleOperStringToOpear; - private static BiMap negatives; + private static final BiMap negatives; - private static BiMap simpleReverses; + private static final BiMap simpleReverses; static { methodNameToOpear = new HashMap<>(); @@ -161,7 +161,7 @@ public Boolean isSimpleOperator() { private String name; - private SQLExpr nameExpr; + private final SQLExpr nameExpr; private Object value; @@ -173,7 +173,7 @@ public SQLExpr getValueExpr() { return valueExpr; } - private SQLExpr valueExpr; + private final SQLExpr valueExpr; private OPERATOR OPERATOR; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Having.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Having.java index a53fb0c275..b5a66d5eb5 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Having.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Having.java @@ -44,7 +44,7 @@ public class Having { /** Conditions parsed out of HAVING clause */ private final List conditions; - private HavingParser havingParser; + private final HavingParser havingParser; public List getHavingFields() { return havingParser.getHavingFields(); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/IndexStatement.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/IndexStatement.java index 2a5be5728c..b2efe99327 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/IndexStatement.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/IndexStatement.java @@ -8,8 +8,8 @@ /** Class used to differentiate SHOW and DESCRIBE statements */ public class IndexStatement implements QueryStatement { - private StatementType statementType; - private String query; + private final StatementType statementType; + private final String query; private String indexPattern; private String columnPattern; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/JoinSelect.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/JoinSelect.java index 211b33c68a..a7d18d7a41 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/JoinSelect.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/JoinSelect.java @@ -12,8 +12,8 @@ /** Created by Eliran on 20/8/2015. */ public class JoinSelect extends Query { - private TableOnJoinSelect firstTable; - private TableOnJoinSelect secondTable; + private final TableOnJoinSelect firstTable; + private final TableOnJoinSelect secondTable; private Where connectedWhere; private List hints; private List connectedConditions; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/KVValue.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/KVValue.java index d864cbac12..9488952c2b 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/KVValue.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/KVValue.java @@ -7,7 +7,7 @@ public class KVValue implements Cloneable { public String key; - public Object value; + public final Object value; public KVValue(Object value) { this.value = value; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java index f593d6c428..57280b7df2 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java @@ -12,7 +12,7 @@ public class Order { private String nestedPath; private String name; private String type; - private Field sortField; + private final Field sortField; public boolean isScript() { return sortField != null && sortField.isScriptField(); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Paramer.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Paramer.java index 38ca556199..e3b6f710b6 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Paramer.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Paramer.java @@ -30,7 +30,7 @@ public class Paramer { public String value; public Integer slop; - public Map fieldsBoosts = new HashMap<>(); + public final Map fieldsBoosts = new HashMap<>(); public String type; public Float tieBreaker; public Operator operator; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Query.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Query.java index 6f891e7fc5..0fe302cd22 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Query.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Query.java @@ -12,7 +12,7 @@ public abstract class Query implements QueryStatement { private Where where = null; - private List from = new ArrayList<>(); + private final List from = new ArrayList<>(); public Where getWhere() { return this.where; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java index 2faa8cc6e5..1de86f43dc 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java @@ -36,11 +36,11 @@ public class Select extends Query { "PERCENTILES", "SCRIPTED_METRIC"); - private List hints = new ArrayList<>(); - private List fields = new ArrayList<>(); - private List> groupBys = new ArrayList<>(); + private final List hints = new ArrayList<>(); + private final List fields = new ArrayList<>(); + private final List> groupBys = new ArrayList<>(); private Having having; - private List orderBys = new ArrayList<>(); + private final List orderBys = new ArrayList<>(); private int offset; private Integer rowCount; private boolean containsSubQueries; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Where.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Where.java index d6f767203b..342d9e5521 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Where.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Where.java @@ -22,7 +22,7 @@ public static Where newInstance() { return new Where(CONN.AND); } - private LinkedList wheres = new LinkedList<>(); + private final LinkedList wheres = new LinkedList<>(); protected CONN conn; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/bucketpath/BucketPath.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/bucketpath/BucketPath.java index 635d0062a5..e2f6c6a7e0 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/bucketpath/BucketPath.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/bucketpath/BucketPath.java @@ -15,7 +15,7 @@ *

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html#buckets-path-syntax */ public class BucketPath { - private Deque pathStack = new ArrayDeque<>(); + private final Deque pathStack = new ArrayDeque<>(); public BucketPath add(Path path) { if (pathStack.isEmpty()) { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/hints/Hint.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/hints/Hint.java index b83c63aae1..7a6c445b83 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/hints/Hint.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/hints/Hint.java @@ -7,8 +7,8 @@ /** Created by Eliran on 5/9/2015. */ public class Hint { - private HintType type; - private Object[] params; + private final HintType type; + private final Object[] params; public Hint(HintType type, Object[] params) { this.type = type; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/GetIndexRequestRestListener.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/GetIndexRequestRestListener.java index 58808ee8f3..fbe1cca6f3 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/GetIndexRequestRestListener.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/GetIndexRequestRestListener.java @@ -24,7 +24,7 @@ /** Created by Eliran on 6/10/2015. */ public class GetIndexRequestRestListener extends RestBuilderListener { - private GetIndexRequest getIndexRequest; + private final GetIndexRequest getIndexRequest; public GetIndexRequestRestListener(RestChannel channel, GetIndexRequest getIndexRequest) { super(channel); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorCloseExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorCloseExecutor.java index 222ca5d9fc..b94ef51b7d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorCloseExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorCloseExecutor.java @@ -33,7 +33,7 @@ public class CursorCloseExecutor implements CursorRestExecutor { private static final String SUCCEEDED_TRUE = "{\"succeeded\":true}"; private static final String SUCCEEDED_FALSE = "{\"succeeded\":false}"; - private String cursorId; + private final String cursorId; public CursorCloseExecutor(String cursorId) { this.cursorId = cursorId; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorResultExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorResultExecutor.java index 4947d06b2f..14ca3aea62 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorResultExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/cursor/CursorResultExecutor.java @@ -41,8 +41,8 @@ public class CursorResultExecutor implements CursorRestExecutor { - private String cursorId; - private Format format; + private final String cursorId; + private final Format format; private static final Logger LOG = LogManager.getLogger(CursorResultExecutor.class); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DataRows.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DataRows.java index fc153afae8..514d016866 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DataRows.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DataRows.java @@ -11,9 +11,9 @@ public class DataRows implements Iterable { - private long size; - private long totalHits; - private List rows; + private final long size; + private final long totalHits; + private final List rows; public DataRows(long size, long totalHits, List rows) { this.size = size; @@ -61,7 +61,7 @@ public void remove() { // Inner class for Row object public static class Row { - private Map data; + private final Map data; public Row(Map data) { this.data = data; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFieldFormatter.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFieldFormatter.java index feba13d139..f8dd261be4 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFieldFormatter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFieldFormatter.java @@ -42,7 +42,7 @@ public class DateFieldFormatter { private final Map> dateFieldFormatMap; private final Map fieldAliasMap; - private Set dateColumns; + private final Set dateColumns; public DateFieldFormatter( String indexName, List columns, Map fieldAliasMap) { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFormat.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFormat.java index fc9237918c..abb04d7f81 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFormat.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DateFormat.java @@ -14,7 +14,7 @@ public class DateFormat { - private static Map formatMap = new HashMap<>(); + private static final Map formatMap = new HashMap<>(); static { // Special cases that are parsed separately @@ -104,31 +104,31 @@ public static String getFormattedDate(java.util.Date date, String dateFormat) { } private static class Date { - static String BASIC_DATE = "yyyyMMdd"; - static String BASIC_ORDINAL_DATE = "yyyyDDD"; - static String BASIC_WEEK_DATE = "YYYY'W'wwu"; + static final String BASIC_DATE = "yyyyMMdd"; + static final String BASIC_ORDINAL_DATE = "yyyyDDD"; + static final String BASIC_WEEK_DATE = "YYYY'W'wwu"; - static String DATE = "yyyy-MM-dd"; - static String ORDINAL_DATE = "yyyy-DDD"; + static final String DATE = "yyyy-MM-dd"; + static final String ORDINAL_DATE = "yyyy-DDD"; - static String YEAR = "yyyy"; - static String YEAR_MONTH = "yyyy-MM"; + static final String YEAR = "yyyy"; + static final String YEAR_MONTH = "yyyy-MM"; - static String WEEK_DATE = "YYYY-'W'ww-u"; - static String WEEKYEAR = "YYYY"; - static String WEEKYEAR_WEEK = "YYYY-'W'ww"; + static final String WEEK_DATE = "YYYY-'W'ww-u"; + static final String WEEKYEAR = "YYYY"; + static final String WEEKYEAR_WEEK = "YYYY-'W'ww"; } private static class Time { - static String T = "'T'"; - static String BASIC_TIME = "HHmmss"; - static String TIME = "HH:mm:ss"; + static final String T = "'T'"; + static final String BASIC_TIME = "HHmmss"; + static final String TIME = "HH:mm:ss"; - static String HOUR = "HH"; - static String HOUR_MINUTE = "HH:mm"; + static final String HOUR = "HH"; + static final String HOUR_MINUTE = "HH:mm"; - static String MILLIS = ".SSS"; - static String TZ = "Z"; - static String TZZ = "XX"; + static final String MILLIS = ".SSS"; + static final String TZ = "Z"; + static final String TZZ = "XX"; } } diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java index 24afb0a7af..2e040d78fb 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DeleteResultSet.java @@ -13,8 +13,8 @@ import org.opensearch.sql.legacy.domain.Delete; public class DeleteResultSet extends ResultSet { - private Delete query; - private Object queryResult; + private final Delete query; + private final Object queryResult; public static final String DELETED = "deleted_rows"; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DescribeResultSet.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DescribeResultSet.java index eba6db2453..74df2ddeeb 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DescribeResultSet.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/DescribeResultSet.java @@ -29,8 +29,8 @@ public class DescribeResultSet extends ResultSet { */ public static final String DEFAULT_OBJECT_DATATYPE = "object"; - private IndexStatement statement; - private Object queryResult; + private final IndexStatement statement; + private final Object queryResult; public DescribeResultSet(Client client, IndexStatement statement, Object queryResult) { this.client = client; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ErrorMessage.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ErrorMessage.java index aa0d02bed8..b75689ba9c 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ErrorMessage.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ErrorMessage.java @@ -10,12 +10,12 @@ public class ErrorMessage { - protected E exception; + protected final E exception; - private int status; - private String type; - private String reason; - private String details; + private final int status; + private final String type; + private final String reason; + private final String details; public ErrorMessage(E exception, int status) { this.exception = exception; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Protocol.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Protocol.java index e6ea767e17..95600d234a 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Protocol.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Protocol.java @@ -36,7 +36,7 @@ public class Protocol { static final int ERROR_STATUS = 500; private final String formatType; - private int status; + private final int status; private long size; private long total; private ResultSet resultSet; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Schema.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Schema.java index b29369f713..e2946e946b 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Schema.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/Schema.java @@ -19,7 +19,7 @@ public class Schema implements Iterable { private String indexName; private List columns; - private static Set types; + private static final Set types; static { types = getTypes(); @@ -121,10 +121,10 @@ public String nameLowerCase() { public static class Column { private final String name; - private String alias; + private final String alias; private final Type type; - private boolean identifiedByAlias; + private final boolean identifiedByAlias; public Column(String name, String alias, Type type, boolean identifiedByAlias) { this.name = name; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/SelectResultSet.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/SelectResultSet.java index bc5c1fb162..84b7c00857 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/SelectResultSet.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/SelectResultSet.java @@ -70,7 +70,7 @@ public class SelectResultSet extends ResultSet { private final String formatType; private Query query; - private Object queryResult; + private final Object queryResult; private boolean selectAll; private String indexName; @@ -82,11 +82,11 @@ public class SelectResultSet extends ResultSet { private long totalHits; private long internalTotalHits; private List rows; - private Cursor cursor; + private final Cursor cursor; private DateFieldFormatter dateFieldFormatter; // alias -> base field name - private Map fieldAliasMap = new HashMap<>(); + private final Map fieldAliasMap = new HashMap<>(); public SelectResultSet( Client client, diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ShowResultSet.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ShowResultSet.java index 263bf1e7db..9b7d15807b 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ShowResultSet.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/format/ShowResultSet.java @@ -22,8 +22,8 @@ public class ShowResultSet extends ResultSet { private static final String TABLE_TYPE = "BASE TABLE"; - private IndexStatement statement; - private Object queryResult; + private final IndexStatement statement; + private final Object queryResult; public ShowResultSet(Client client, IndexStatement statement, Object queryResult) { this.client = client; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java index e5011d1af8..5ff52cf657 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/ElasticJoinExecutor.java @@ -45,11 +45,11 @@ public abstract class ElasticJoinExecutor extends ElasticHitsExecutor { protected List results; // Keep list to avoid copy to new array in SearchHits - protected MetaSearchResult metaResults; + protected final MetaSearchResult metaResults; protected final int MAX_RESULTS_ON_ONE_FETCH = 10000; - private Set aliasesOnReturn; - private boolean allFieldsReturn; - protected String[] indices; + private final Set aliasesOnReturn; + private final boolean allFieldsReturn; + protected final String[] indices; protected ElasticJoinExecutor(Client client, JoinRequestBuilder requestBuilder) { metaResults = new MetaSearchResult(); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinComparisonStructure.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinComparisonStructure.java index 8216feac66..cf81a6fe49 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinComparisonStructure.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinComparisonStructure.java @@ -15,8 +15,8 @@ /** Created by Eliran on 2/11/2015. */ public class HashJoinComparisonStructure { - private HashMap>> comparisonIDtoComparisonFields; - private HashMap> comparisonIDtoComparisonHash; + private final HashMap>> comparisonIDtoComparisonFields; + private final HashMap> comparisonIDtoComparisonHash; public HashJoinComparisonStructure(List>> t1ToT2FieldsComparisons) { comparisonIDtoComparisonFields = new HashMap<>(); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinElasticExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinElasticExecutor.java index 0e33ab9eef..46b31b447d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinElasticExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/HashJoinElasticExecutor.java @@ -34,11 +34,11 @@ /** Created by Eliran on 22/8/2015. */ public class HashJoinElasticExecutor extends ElasticJoinExecutor { - private HashJoinElasticRequestBuilder requestBuilder; + private final HashJoinElasticRequestBuilder requestBuilder; private boolean useQueryTermsFilterOptimization = false; private final int MAX_RESULTS_FOR_FIRST_TABLE = 100000; - HashJoinComparisonStructure hashJoinComparisonStructure; - private Set alreadyMatched; + final HashJoinComparisonStructure hashJoinComparisonStructure; + private final Set alreadyMatched; public HashJoinElasticExecutor(Client client, HashJoinElasticRequestBuilder requestBuilder) { super(client, requestBuilder); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/NestedLoopsElasticExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/NestedLoopsElasticExecutor.java index 9356a0058e..f4e4347e06 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/NestedLoopsElasticExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/join/NestedLoopsElasticExecutor.java @@ -378,8 +378,8 @@ private void reverseOrderOfCondition(Condition cond, String t1Alias, String t2Al } private class FetchWithScrollResponse { - private SearchResponse response; - private boolean needScrollForFirstTable; + private final SearchResponse response; + private final boolean needScrollForFirstTable; private FetchWithScrollResponse(SearchResponse response, boolean needScrollForFirstTable) { this.response = response; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/ComperableHitResult.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/ComperableHitResult.java index fa3514600b..f799cd63d2 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/ComperableHitResult.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/ComperableHitResult.java @@ -15,10 +15,10 @@ /** Created by Eliran on 9/9/2016. */ public class ComperableHitResult { - private SearchHit hit; - private String comperator; + private final SearchHit hit; + private final String comperator; private boolean isAllNull; - private Map flattenMap; + private final Map flattenMap; public ComperableHitResult(SearchHit hit, String[] fieldsOrder, String seperator) { this.hit = hit; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusExecutor.java index 06186d0695..a3f8596eb4 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusExecutor.java @@ -42,9 +42,9 @@ /** Created by Eliran on 26/8/2016. */ public class MinusExecutor extends ElasticHitsExecutor { - private MultiQueryRequestBuilder builder; + private final MultiQueryRequestBuilder builder; private SearchHits minusHits; - private boolean useTermsOptimization; + private final boolean useTermsOptimization; private boolean termsOptimizationWithToLower; private boolean useScrolling; private int maxDocsToFetchOnFirstTable; @@ -52,7 +52,7 @@ public class MinusExecutor extends ElasticHitsExecutor { private int maxDocsToFetchOnEachScrollShard; private String[] fieldsOrderFirstTable; private String[] fieldsOrderSecondTable; - private String seperator; + private final String seperator; public MinusExecutor(Client client, MultiQueryRequestBuilder builder) { this.client = client; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusOneFieldAndOptimizationResult.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusOneFieldAndOptimizationResult.java index 3d7206ab13..5843e0d931 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusOneFieldAndOptimizationResult.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/MinusOneFieldAndOptimizationResult.java @@ -10,8 +10,8 @@ /** Created by Eliran on 26/8/2016. */ class MinusOneFieldAndOptimizationResult { - private Set fieldValues; - private SearchHit someHit; + private final Set fieldValues; + private final SearchHit someHit; MinusOneFieldAndOptimizationResult(Set fieldValues, SearchHit someHit) { this.fieldValues = fieldValues; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/UnionExecutor.java b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/UnionExecutor.java index 375c40a5c1..024d1bb4c3 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/UnionExecutor.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/executor/multi/UnionExecutor.java @@ -25,7 +25,7 @@ /** Created by Eliran on 21/8/2016. */ public class UnionExecutor extends ElasticHitsExecutor { - private MultiQueryRequestBuilder multiQueryBuilder; + private final MultiQueryRequestBuilder multiQueryBuilder; private SearchHits results; private int currentId; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/BasicCounter.java b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/BasicCounter.java index 88d5f817e8..5c238521a0 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/BasicCounter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/BasicCounter.java @@ -9,7 +9,7 @@ public class BasicCounter implements Counter { - private LongAdder count = new LongAdder(); + private final LongAdder count = new LongAdder(); @Override public void increment() { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/GaugeMetric.java b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/GaugeMetric.java index 2f7c269351..150862e4d1 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/GaugeMetric.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/GaugeMetric.java @@ -10,7 +10,7 @@ /** Gauge metric, an instant value like cpu usage, state and so on */ public class GaugeMetric extends Metric { - private Supplier loadValue; + private final Supplier loadValue; public GaugeMetric(String name, Supplier supplier) { super(name); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metric.java b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metric.java index 956e0f558c..ea543cbd2d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metric.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metric.java @@ -9,7 +9,7 @@ public abstract class Metric implements java.io.Serializable { private static final long serialVersionUID = 1L; - private String name; + private final String name; public Metric(String name) { this.name = name; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/MetricName.java b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/MetricName.java index 72960944b6..7c2a7cb824 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/MetricName.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/MetricName.java @@ -50,7 +50,7 @@ public enum MetricName { EMR_BATCH_QUERY_JOBS_CREATION_COUNT("emr_batch_jobs_creation_count"), STREAMING_JOB_HOUSEKEEPER_TASK_FAILURE_COUNT("streaming_job_housekeeper_task_failure_count"); - private String name; + private final String name; MetricName(String name) { this.name = name; @@ -64,7 +64,7 @@ public static List getNames() { return Arrays.stream(MetricName.values()).map(v -> v.name).collect(Collectors.toList()); } - private static Set NUMERICAL_METRIC = + private static final Set NUMERICAL_METRIC = new ImmutableSet.Builder() .add(PPL_REQ_TOTAL) .add(PPL_REQ_COUNT_TOTAL) diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metrics.java b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metrics.java index 858f9e5cef..a47f0e12bd 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metrics.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/Metrics.java @@ -12,8 +12,9 @@ public class Metrics { - private static Metrics metrics = new Metrics(); - private ConcurrentHashMap registeredMetricsByName = new ConcurrentHashMap<>(); + private static final Metrics metrics = new Metrics(); + private final ConcurrentHashMap registeredMetricsByName = + new ConcurrentHashMap<>(); public static Metrics getInstance() { return metrics; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/NumericMetric.java b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/NumericMetric.java index ee6d373f8f..93bc9485bc 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/metrics/NumericMetric.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/metrics/NumericMetric.java @@ -7,7 +7,7 @@ public class NumericMetric extends Metric { - private Counter counter; + private final Counter counter; public NumericMetric(String name, Counter counter) { super(name); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/parser/CaseWhenParser.java b/legacy/src/main/java/org/opensearch/sql/legacy/parser/CaseWhenParser.java index d55ee64601..9b26bf4608 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/parser/CaseWhenParser.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/parser/CaseWhenParser.java @@ -21,9 +21,9 @@ /** Created by allwefantasy on 9/3/16. */ public class CaseWhenParser { - private SQLCaseExpr caseExpr; - private String alias; - private String tableAlias; + private final SQLCaseExpr caseExpr; + private final String alias; + private final String tableAlias; public CaseWhenParser(SQLCaseExpr caseExpr, String alias, String tableAlias) { this.alias = alias; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/parser/ElasticSqlExprParser.java b/legacy/src/main/java/org/opensearch/sql/legacy/parser/ElasticSqlExprParser.java index be9c2f9652..ed9cc2cd3d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/parser/ElasticSqlExprParser.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/parser/ElasticSqlExprParser.java @@ -193,7 +193,7 @@ public SQLExpr primary() { return expr; } - public static String[] AGGREGATE_FUNCTIONS = { + public static final String[] AGGREGATE_FUNCTIONS = { "AVG", "COUNT", "GROUP_CONCAT", "MAX", "MIN", "STDDEV", "SUM" }; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java b/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java index da08f81453..ca0fbb8393 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java @@ -43,7 +43,7 @@ * @author ansj */ public class FieldMaker { - private SQLFunctions sqlFunctions = new SQLFunctions(); + private final SQLFunctions sqlFunctions = new SQLFunctions(); public Field makeField(SQLExpr expr, String alias, String tableAlias) throws SqlParseException { Field field = makeFieldImpl(expr, alias, tableAlias); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/parser/SqlParser.java b/legacy/src/main/java/org/opensearch/sql/legacy/parser/SqlParser.java index 947533630b..c380ded176 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/parser/SqlParser.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/parser/SqlParser.java @@ -55,7 +55,7 @@ * @author ansj */ public class SqlParser { - private FieldMaker fieldMaker = new FieldMaker(); + private final FieldMaker fieldMaker = new FieldMaker(); public SqlParser() {} diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/parser/SubQueryExpression.java b/legacy/src/main/java/org/opensearch/sql/legacy/parser/SubQueryExpression.java index e9b0797d00..663de4f4b7 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/parser/SubQueryExpression.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/parser/SubQueryExpression.java @@ -11,7 +11,7 @@ public class SubQueryExpression { private Object[] values; private Select select; - private String returnField; + private final String returnField; public SubQueryExpression(Select innerSelect) { this.select = innerSelect; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/parser/WhereParser.java b/legacy/src/main/java/org/opensearch/sql/legacy/parser/WhereParser.java index a329d1ed52..4ba25f9fad 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/parser/WhereParser.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/parser/WhereParser.java @@ -44,12 +44,12 @@ /** Created by allwefantasy on 9/2/16. */ public class WhereParser { - private FieldMaker fieldMaker; + private final FieldMaker fieldMaker; private MySqlSelectQueryBlock query; private SQLDeleteStatement delete; private SQLExpr where; - private SqlParser sqlParser; + private final SqlParser sqlParser; public WhereParser(SqlParser sqlParser, MySqlSelectQueryBlock query, FieldMaker fieldMaker) { this.sqlParser = sqlParser; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImpl.java b/legacy/src/main/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImpl.java index 8d61c03388..db3530e91e 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImpl.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImpl.java @@ -24,7 +24,7 @@ /** Handler for Point In Time */ public class PointInTimeHandlerImpl implements PointInTimeHandler { - private Client client; + private final Client client; private String[] indices; @Getter @Setter private String pitId; private static final Logger LOG = LogManager.getLogger(); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/AggregationQueryAction.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/AggregationQueryAction.java index 57af269001..c7a1f82df1 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/AggregationQueryAction.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/AggregationQueryAction.java @@ -41,7 +41,7 @@ public class AggregationQueryAction extends QueryAction { private final Select select; - private AggMaker aggMaker = new AggMaker(); + private final AggMaker aggMaker = new AggMaker(); private SearchRequestBuilder request; public AggregationQueryAction(Client client, Select select) { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/QueryAction.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/QueryAction.java index c9b39d2f97..4d40701964 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/QueryAction.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/QueryAction.java @@ -36,8 +36,8 @@ */ public abstract class QueryAction { - protected Query query; - protected Client client; + protected final Query query; + protected final Client client; protected SqlRequest sqlRequest = SqlRequest.NULL; protected ColumnTypeProvider scriptColumnType; protected Format format; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlElasticDeleteByQueryRequestBuilder.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlElasticDeleteByQueryRequestBuilder.java index 2203cbb39e..1ff35df531 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlElasticDeleteByQueryRequestBuilder.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlElasticDeleteByQueryRequestBuilder.java @@ -13,7 +13,7 @@ /** Created by Eliran on 19/8/2015. */ public class SqlElasticDeleteByQueryRequestBuilder implements SqlElasticRequestBuilder { - DeleteByQueryRequestBuilder deleteByQueryRequestBuilder; + final DeleteByQueryRequestBuilder deleteByQueryRequestBuilder; public SqlElasticDeleteByQueryRequestBuilder( DeleteByQueryRequestBuilder deleteByQueryRequestBuilder) { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlOpenSearchRequestBuilder.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlOpenSearchRequestBuilder.java index 2beb16837b..d15debb0fd 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlOpenSearchRequestBuilder.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/SqlOpenSearchRequestBuilder.java @@ -11,7 +11,7 @@ /** Created by Eliran on 19/8/2015. */ public class SqlOpenSearchRequestBuilder implements SqlElasticRequestBuilder { - ActionRequestBuilder requestBuilder; + final ActionRequestBuilder requestBuilder; public SqlOpenSearchRequestBuilder(ActionRequestBuilder requestBuilder) { this.requestBuilder = requestBuilder; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/join/BackOffRetryStrategy.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/join/BackOffRetryStrategy.java index d767268cb1..3386298802 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/join/BackOffRetryStrategy.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/join/BackOffRetryStrategy.java @@ -31,9 +31,9 @@ public class BackOffRetryStrategy { private static final int threshold = 85; - private static IdentityHashMap> memUse = new IdentityHashMap<>(); + private static final IdentityHashMap> memUse = new IdentityHashMap<>(); - private static AtomicLong mem = new AtomicLong(0L); + private static final AtomicLong mem = new AtomicLong(0L); private static long lastTimeoutCleanTime = System.currentTimeMillis(); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/join/JoinRequestBuilder.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/join/JoinRequestBuilder.java index 82ebd1b225..0a9917a624 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/join/JoinRequestBuilder.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/join/JoinRequestBuilder.java @@ -21,8 +21,8 @@ public class JoinRequestBuilder implements SqlElasticRequestBuilder { private MultiSearchRequest multi; - private TableInJoinRequestBuilder firstTable; - private TableInJoinRequestBuilder secondTable; + private final TableInJoinRequestBuilder firstTable; + private final TableInJoinRequestBuilder secondTable; private SQLJoinTableSource.JoinType joinType; private int totalLimit; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/join/OpenSearchJoinQueryAction.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/join/OpenSearchJoinQueryAction.java index 7068ddf9a2..b317ef9740 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/join/OpenSearchJoinQueryAction.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/join/OpenSearchJoinQueryAction.java @@ -22,7 +22,7 @@ /** Created by Eliran on 15/9/2015. */ public abstract class OpenSearchJoinQueryAction extends QueryAction { - protected JoinSelect joinSelect; + protected final JoinSelect joinSelect; public OpenSearchJoinQueryAction(Client client, JoinSelect joinSelect) { super(client, joinSelect); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java index dcb703cd33..75753ce24f 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java @@ -65,7 +65,7 @@ public class AggMaker { /** The mapping bettwen group fieldName or Alias to the KVValue. */ - private Map groupMap = new HashMap<>(); + private final Map groupMap = new HashMap<>(); private Where where; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryAction.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryAction.java index a9eb6113f7..549fdfc077 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryAction.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryAction.java @@ -19,7 +19,7 @@ /** Created by Eliran on 19/8/2016. */ public class MultiQueryAction extends QueryAction { - private MultiQuerySelect multiQuerySelect; + private final MultiQuerySelect multiQuerySelect; public MultiQueryAction(Client client, MultiQuerySelect multiSelect) { super(client, null); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryRequestBuilder.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryRequestBuilder.java index b4e92a8de6..a02f4037c7 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryRequestBuilder.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQueryRequestBuilder.java @@ -27,10 +27,10 @@ public class MultiQueryRequestBuilder implements SqlElasticRequestBuilder { private SearchRequestBuilder firstSearchRequest; private SearchRequestBuilder secondSearchRequest; - private Map firstTableFieldToAlias; - private Map secondTableFieldToAlias; - private MultiQuerySelect multiQuerySelect; - private SQLUnionOperator relation; + private final Map firstTableFieldToAlias; + private final Map secondTableFieldToAlias; + private final MultiQuerySelect multiQuerySelect; + private final SQLUnionOperator relation; public MultiQueryRequestBuilder(MultiQuerySelect multiQuerySelect) { this.multiQuerySelect = multiQuerySelect; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQuerySelect.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQuerySelect.java index 72e7232a30..6a573c999f 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQuerySelect.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/multi/MultiQuerySelect.java @@ -10,9 +10,9 @@ /** Created by Eliran on 19/8/2016. */ public class MultiQuerySelect { - private SQLUnionOperator operation; - private Select firstSelect; - private Select secondSelect; + private final SQLUnionOperator operation; + private final Select firstSelect; + private final Select secondSelect; public MultiQuerySelect(SQLUnionOperator operation, Select firstSelect, Select secondSelect) { this.operation = operation; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/converter/SQLAggregationParser.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/converter/SQLAggregationParser.java index b54e260fd4..0944339939 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/converter/SQLAggregationParser.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/converter/SQLAggregationParser.java @@ -39,7 +39,7 @@ public class SQLAggregationParser { private final ColumnTypeProvider columnTypeProvider; private Context context; - @Getter private List columnNodes = new ArrayList<>(); + @Getter private final List columnNodes = new ArrayList<>(); public void parse(MySqlSelectQueryBlock queryBlock) { context = new Context(constructSQLExprAliasMapFromSelect(queryBlock)); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/BindingTupleQueryPlanner.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/BindingTupleQueryPlanner.java index a8fb7cc53c..e4cb323e71 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/BindingTupleQueryPlanner.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/BindingTupleQueryPlanner.java @@ -18,8 +18,8 @@ /** The definition of QueryPlanner which return the {@link BindingTuple} as result. */ public class BindingTupleQueryPlanner { - private PhysicalOperator physicalOperator; - @Getter private List columnNodes; + private final PhysicalOperator physicalOperator; + @Getter private final List columnNodes; public BindingTupleQueryPlanner( Client client, SQLQueryExpr sqlExpr, ColumnTypeProvider columnTypeProvider) { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/ExecuteParams.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/ExecuteParams.java index c5ed48a514..86ab26876a 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/ExecuteParams.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/core/ExecuteParams.java @@ -11,7 +11,7 @@ public class ExecuteParams { /** Mapping from type to parameters */ - private EnumMap params = new EnumMap<>(ExecuteParamType.class); + private final EnumMap params = new EnumMap<>(ExecuteParamType.class); public void add(ExecuteParamType type, T param) { params.put(type, param); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/logical/node/Group.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/logical/node/Group.java index da94ae74da..79724db7d9 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/logical/node/Group.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/logical/node/Group.java @@ -14,10 +14,10 @@ public class Group implements LogicalOperator { /** Optional pushed down projection */ - private Project project; + private final Project project; /** Optional pushed down filter (selection) */ - private Filter filter; + private final Filter filter; /** Required table scan operator */ private final TableScan tableScan; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/estimation/Estimation.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/estimation/Estimation.java index 72ffbd4652..982b400821 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/estimation/Estimation.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/estimation/Estimation.java @@ -23,7 +23,7 @@ public class Estimation implements LogicalPlanVisitor { /** Optimal physical operator for logical operator based on completed estimation */ - private Map> optimalOps = new IdentityHashMap<>(); + private final Map> optimalOps = new IdentityHashMap<>(); /** Keep tracking of the operator that exit visit() */ private PhysicalOperator root; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/CombinedRow.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/CombinedRow.java index b1fb43441e..1682c14042 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/CombinedRow.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/CombinedRow.java @@ -18,8 +18,8 @@ */ public class CombinedRow { - private Row rightRow; - private Collection> leftRows; + private final Row rightRow; + private final Collection> leftRows; public CombinedRow(Row rightRow, Collection> leftRows) { this.rightRow = rightRow; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/JoinAlgorithm.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/JoinAlgorithm.java index 9f2c9e4174..0c0d50258d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/JoinAlgorithm.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/JoinAlgorithm.java @@ -51,7 +51,7 @@ public abstract class JoinAlgorithm extends BatchPhysicalOperator { private final Set> leftMismatch; /** Hash table for right table probing */ - protected HashTable hashTable; + protected final HashTable hashTable; /** Execute params to reset right side for each left block */ protected ExecuteParams params; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/ListHashTable.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/ListHashTable.java index baf0af8c86..37486045b7 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/ListHashTable.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/ListHashTable.java @@ -15,7 +15,7 @@ /** List implementation to avoid normal hash table degrading into linked list. */ public class ListHashTable implements HashTable { - private List> rows = new ArrayList<>(); + private final List> rows = new ArrayList<>(); @Override public void add(Row row) { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/Stats.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/Stats.java index 3ff4662ce4..ac830d2595 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/Stats.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/Stats.java @@ -19,7 +19,7 @@ public class Stats { /** Client connection to OpenSearch cluster (unused now) */ - private Client client; + private final Client client; public Stats(Client client) { this.client = client; @@ -31,8 +31,8 @@ public MemStats collectMemStats() { /** Statistics data class for memory usage */ public static class MemStats { - private long free; - private long total; + private final long free; + private final long total; public MemStats(long free, long total) { this.free = free; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/AdaptiveBlockSize.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/AdaptiveBlockSize.java index 339e326cc3..a5e7841d69 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/AdaptiveBlockSize.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/AdaptiveBlockSize.java @@ -8,7 +8,7 @@ /** Adaptive block size calculator based on resource usage dynamically. */ public class AdaptiveBlockSize implements BlockSize { - private int upperLimit; + private final int upperLimit; public AdaptiveBlockSize(int upperLimit) { this.upperLimit = upperLimit; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/BlockSize.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/BlockSize.java index 6e5a2703f4..154cc6122f 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/BlockSize.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/resource/blocksize/BlockSize.java @@ -18,7 +18,7 @@ public interface BlockSize { /** Default implementation with fixed block size */ class FixedBlockSize implements BlockSize { - private int blockSize; + private final int blockSize; public FixedBlockSize(int blockSize) { this.blockSize = blockSize; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/request/PreparedStatementRequest.java b/legacy/src/main/java/org/opensearch/sql/legacy/request/PreparedStatementRequest.java index c32e529157..c9ce288784 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/request/PreparedStatementRequest.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/request/PreparedStatementRequest.java @@ -10,8 +10,8 @@ public class PreparedStatementRequest extends SqlRequest { - private List parameters; - private String sqlTemplate; + private final List parameters; + private final String sqlTemplate; public PreparedStatementRequest( String sql, JSONObject payloadJson, List parameters) { @@ -117,7 +117,7 @@ public enum ParameterType { } public static class PreparedStatementParameter { - protected T value; + protected final T value; public PreparedStatementParameter(T value) { this.value = value; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/join/JoinRewriteRule.java b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/join/JoinRewriteRule.java index 884784ed42..0ce61966dc 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/join/JoinRewriteRule.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/join/JoinRewriteRule.java @@ -205,10 +205,10 @@ public String getAlias() { } /** Table Name. */ - private String name; + private final String name; /** Table Alias. */ - private String alias; + private final String alias; Table(String name, String alias) { this.name = name; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/matchtoterm/TermFieldRewriter.java b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/matchtoterm/TermFieldRewriter.java index 922e3b930e..d7a1000179 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/matchtoterm/TermFieldRewriter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/matchtoterm/TermFieldRewriter.java @@ -40,8 +40,8 @@ */ public class TermFieldRewriter extends MySqlASTVisitorAdapter { - private Deque environment = new ArrayDeque<>(); - private TermRewriterFilter filterType; + private final Deque environment = new ArrayDeque<>(); + private final TermRewriterFilter filterType; public TermFieldRewriter() { this.filterType = TermRewriterFilter.COMMA; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/NestedFieldRewriter.java b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/NestedFieldRewriter.java index 46afbb8ca1..59f415f306 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/NestedFieldRewriter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/NestedFieldRewriter.java @@ -57,7 +57,7 @@ public class NestedFieldRewriter extends MySqlASTVisitorAdapter { * Scope stack to record the state (nested field names etc) for current query. In the case of * subquery, the active scope of current query is the top element of the stack. */ - private Deque environment = new ArrayDeque<>(); + private final Deque environment = new ArrayDeque<>(); /** * Rewrite FROM here to make sure FROM statement always be visited before other statement in diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/Scope.java b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/Scope.java index f65d7f166b..e9c2729716 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/Scope.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/nestedfield/Scope.java @@ -26,13 +26,13 @@ class Scope { * Mapping from nested field path alias to path full name in FROM. eg. e in {e => employees} in * "FROM t.employees e" */ - private Map aliasFullPaths = new HashMap<>(); + private final Map aliasFullPaths = new HashMap<>(); /** * Mapping from binary operation condition (in WHERE) to nested field tag (full path for nested, * EMPTY for non-nested field) */ - private Map conditionTags = new IdentityHashMap<>(); + private final Map conditionTags = new IdentityHashMap<>(); String getParentAlias() { return parentAlias; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/ordinal/OrdinalRewriterRule.java b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/ordinal/OrdinalRewriterRule.java index ed853823ce..7a1ac49b0e 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/ordinal/OrdinalRewriterRule.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/ordinal/OrdinalRewriterRule.java @@ -68,13 +68,13 @@ private void changeOrdinalAliasInGroupAndOrderBy( root.accept( new MySqlASTVisitorAdapter() { - private String groupException = "Invalid ordinal [%s] specified in [GROUP BY %s]"; - private String orderException = "Invalid ordinal [%s] specified in [ORDER BY %s]"; + private final String groupException = "Invalid ordinal [%s] specified in [GROUP BY %s]"; + private final String orderException = "Invalid ordinal [%s] specified in [ORDER BY %s]"; - private List groupSelectList = + private final List groupSelectList = ((MySqlSelectQueryBlock) exprGroup.getSubQuery().getQuery()).getSelectList(); - private List orderSelectList = + private final List orderSelectList = ((MySqlSelectQueryBlock) exprOrder.getSubQuery().getQuery()).getSelectList(); @Override diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/SubQueryRewriteRule.java b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/SubQueryRewriteRule.java index 5177b2d6d3..0fa55fe59d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/SubQueryRewriteRule.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/SubQueryRewriteRule.java @@ -13,7 +13,7 @@ /** Subquery Rewriter Rule. */ public class SubQueryRewriteRule implements RewriteRule { - private FindSubQuery findAllSubQuery = new FindSubQuery(); + private final FindSubQuery findAllSubQuery = new FindSubQuery(); @Override public boolean match(SQLQueryExpr expr) throws SQLFeatureNotSupportedException { diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/rewriter/SubqueryAliasRewriter.java b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/rewriter/SubqueryAliasRewriter.java index 7176bd030c..955cf258b1 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/rewriter/SubqueryAliasRewriter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/rewriter/subquery/rewriter/SubqueryAliasRewriter.java @@ -152,10 +152,10 @@ public String getAlias() { } /** Table Name. */ - private String name; + private final String name; /** Table Alias. */ - private String alias; + private final String alias; Table(String name, String alias) { this.name = name; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/BoundingBoxFilterParams.java b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/BoundingBoxFilterParams.java index fb62f60ae7..3fe292e94d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/BoundingBoxFilterParams.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/BoundingBoxFilterParams.java @@ -7,8 +7,8 @@ /** Created by Eliran on 1/8/2015. */ public class BoundingBoxFilterParams { - private Point topLeft; - private Point bottomRight; + private final Point topLeft; + private final Point bottomRight; public BoundingBoxFilterParams(Point topLeft, Point bottomRight) { this.topLeft = topLeft; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/CellFilterParams.java b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/CellFilterParams.java index 6c50c17467..8c169814cd 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/CellFilterParams.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/CellFilterParams.java @@ -7,9 +7,9 @@ /** Created by Eliran on 15/8/2015. */ public class CellFilterParams { - private Point geohashPoint; - private int precision; - private boolean neighbors; + private final Point geohashPoint; + private final int precision; + private final boolean neighbors; public CellFilterParams(Point geohashPoint, int precision, boolean neighbors) { this.geohashPoint = geohashPoint; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/DistanceFilterParams.java b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/DistanceFilterParams.java index 8c419de58d..32027dec42 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/DistanceFilterParams.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/DistanceFilterParams.java @@ -7,8 +7,8 @@ /** Created by Eliran on 1/8/2015. */ public class DistanceFilterParams { - private String distance; - private Point from; + private final String distance; + private final Point from; public DistanceFilterParams(String distance, Point from) { this.distance = distance; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/Point.java b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/Point.java index f3f8639a1c..a5ed003c3d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/Point.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/Point.java @@ -7,8 +7,8 @@ /** Created by Eliran on 1/8/2015. */ public class Point { - private double lon; - private double lat; + private final double lon; + private final double lat; public Point(double lon, double lat) { this.lon = lon; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/PolygonFilterParams.java b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/PolygonFilterParams.java index 1aeddb24a4..edf2deced4 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/PolygonFilterParams.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/PolygonFilterParams.java @@ -9,7 +9,7 @@ /** Created by Eliran on 15/8/2015. */ public class PolygonFilterParams { - private List polygon; + private final List polygon; public PolygonFilterParams(List polygon) { this.polygon = polygon; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/RangeDistanceFilterParams.java b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/RangeDistanceFilterParams.java index 0bdb01c3ce..6dd25ad2cf 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/RangeDistanceFilterParams.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/RangeDistanceFilterParams.java @@ -7,7 +7,7 @@ /** Created by Eliran on 15/8/2015. */ public class RangeDistanceFilterParams extends DistanceFilterParams { - private String distanceTo; + private final String distanceTo; public RangeDistanceFilterParams(String distanceFrom, String distanceTo, Point from) { super(distanceFrom, from); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/SpatialParamsFactory.java b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/SpatialParamsFactory.java index 5e1102994e..d9de1e1a00 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/spatial/SpatialParamsFactory.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/spatial/SpatialParamsFactory.java @@ -13,7 +13,7 @@ /** Created by Eliran on 1/8/2015. */ public class SpatialParamsFactory { - public static Set allowedMethods; + public static final Set allowedMethods; static { allowedMethods = new HashSet<>(); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/utils/SQLFunctions.java b/legacy/src/main/java/org/opensearch/sql/legacy/utils/SQLFunctions.java index d46a80f6d3..a6a9199533 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/utils/SQLFunctions.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/utils/SQLFunctions.java @@ -112,7 +112,7 @@ public class SQLFunctions { .flatMap(Set::stream) .collect(Collectors.toSet()); - private Map generatedIds = new HashMap<>(); + private final Map generatedIds = new HashMap<>(); /** * Generates next id for given method name. The id's are increasing for each method name, so diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SyntaxAnalysisTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SyntaxAnalysisTest.java index 765bb0616e..4275b6152e 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SyntaxAnalysisTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/SyntaxAnalysisTest.java @@ -22,9 +22,9 @@ public class SyntaxAnalysisTest { /** public accessor is required by @Rule annotation */ - @Rule public ExpectedException exception = ExpectedException.none(); + @Rule public final ExpectedException exception = ExpectedException.none(); - private OpenSearchLegacySqlAnalyzer analyzer = + private final OpenSearchLegacySqlAnalyzer analyzer = new OpenSearchLegacySqlAnalyzer(new SqlAnalysisConfig(true, true, 1000)); /** In reality exception occurs before reaching new parser for now */ diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerConfigTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerConfigTest.java index 2b9a5e418c..79d42a05b7 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerConfigTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerConfigTest.java @@ -19,7 +19,7 @@ /** Test cases for semantic analysis configuration */ public class SemanticAnalyzerConfigTest extends SemanticAnalyzerTestBase { - @Rule public ExpectedException exceptionWithoutSuggestion = ExpectedException.none(); + @Rule public final ExpectedException exceptionWithoutSuggestion = ExpectedException.none(); @Test public void noAnalysisShouldPerformForNonSelectStatement() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerTestBase.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerTestBase.java index 403c2f49b7..390760af32 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerTestBase.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/SemanticAnalyzerTestBase.java @@ -33,9 +33,9 @@ public abstract class SemanticAnalyzerTestBase { private static final String TEST_MAPPING_FILE = "mappings/semantics.json"; /** public accessor is required by @Rule annotation */ - @Rule public ExpectedException exception = ExpectedException.none(); + @Rule public final ExpectedException exception = ExpectedException.none(); - private OpenSearchLegacySqlAnalyzer analyzer = + private final OpenSearchLegacySqlAnalyzer analyzer = new OpenSearchLegacySqlAnalyzer(new SqlAnalysisConfig(true, true, 1000)); @SuppressWarnings("UnstableApiUsage") diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/scope/TypeSupplierTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/scope/TypeSupplierTest.java index e6090117c1..57d8b3c7bb 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/scope/TypeSupplierTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/semantic/scope/TypeSupplierTest.java @@ -14,7 +14,7 @@ import org.opensearch.sql.legacy.antlr.semantic.types.base.OpenSearchDataType; public class TypeSupplierTest { - @Rule public ExpectedException exception = ExpectedException.none(); + @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void haveOneTypeShouldPass() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/visitor/AntlrSqlParseTreeVisitorTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/visitor/AntlrSqlParseTreeVisitorTest.java index be4b5a5197..2baaa91980 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/antlr/visitor/AntlrSqlParseTreeVisitorTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/antlr/visitor/AntlrSqlParseTreeVisitorTest.java @@ -27,7 +27,7 @@ /** Test cases for AntlrSqlParseTreeVisitor */ public class AntlrSqlParseTreeVisitorTest { - private TypeChecker analyzer = + private final TypeChecker analyzer = new TypeChecker(new SemanticContext()) { @Override public Type visitIndexName(String indexName) { @@ -47,7 +47,7 @@ public Type visitFieldName(String fieldName) { } }; - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void selectNumberShouldReturnNumberAsQueryVisitingResult() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/executor/AsyncRestExecutorTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/executor/AsyncRestExecutorTest.java index 9be2517c4a..eea1c9a87a 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/executor/AsyncRestExecutorTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/executor/AsyncRestExecutorTest.java @@ -43,7 +43,7 @@ public class AsyncRestExecutorTest { @Mock private Client client; - private Map params = emptyMap(); + private final Map params = emptyMap(); @Mock private QueryAction action; diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImplTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImplTest.java index eba4ae0346..d9fcf4e87e 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImplTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/pit/PointInTimeHandlerImplTest.java @@ -38,7 +38,7 @@ public class PointInTimeHandlerImplTest { @Mock private Client mockClient; - private String[] indices = {"index1", "index2"}; + private final String[] indices = {"index1", "index2"}; private PointInTimeHandlerImpl pointInTimeHandlerImpl; private final String PIT_ID = "testId"; private CreatePitResponse mockCreatePitResponse; diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/ErrorMessageFactoryTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/ErrorMessageFactoryTest.java index 09cd9e9efc..31baaced85 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/ErrorMessageFactoryTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/ErrorMessageFactoryTest.java @@ -15,8 +15,8 @@ public class ErrorMessageFactoryTest { - private Throwable nonOpenSearchThrowable = new Throwable(); - private Throwable openSearchThrowable = new OpenSearchException(nonOpenSearchThrowable); + private final Throwable nonOpenSearchThrowable = new Throwable(); + private final Throwable openSearchThrowable = new OpenSearchException(nonOpenSearchThrowable); @Test public void openSearchExceptionShouldCreateEsErrorMessage() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/SqlRequestParamTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/SqlRequestParamTest.java index 3c47832761..0d29b55106 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/SqlRequestParamTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/SqlRequestParamTest.java @@ -19,7 +19,7 @@ import org.opensearch.sql.legacy.request.SqlRequestParam; public class SqlRequestParamTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void shouldReturnTrueIfPrettyParamsIsTrue() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/BinaryExpressionTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/BinaryExpressionTest.java index acc0e9c60e..610930e0e7 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/BinaryExpressionTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/BinaryExpressionTest.java @@ -20,7 +20,7 @@ @RunWith(MockitoJUnitRunner.class) public class BinaryExpressionTest extends ExpressionTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void addIntegerValueShouldPass() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/UnaryExpressionTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/UnaryExpressionTest.java index e030e1c6cf..f049cd843a 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/UnaryExpressionTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/core/UnaryExpressionTest.java @@ -20,7 +20,7 @@ @RunWith(MockitoJUnitRunner.class) public class UnaryExpressionTest extends ExpressionTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void absShouldPass() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/model/ExprValueUtilsTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/model/ExprValueUtilsTest.java index 15fd72a522..846406879d 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/model/ExprValueUtilsTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/expression/model/ExprValueUtilsTest.java @@ -18,7 +18,7 @@ @RunWith(MockitoJUnitRunner.class) public class ExprValueUtilsTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void getIntegerValueWithIntegerExprValueShouldPass() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/BucketPathTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/BucketPathTest.java index c26740a04c..c88874c3f1 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/BucketPathTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/BucketPathTest.java @@ -15,7 +15,7 @@ public class BucketPathTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); private final Path agg1 = Path.getAggPath("projects@NESTED"); private final Path agg2 = Path.getAggPath("projects@FILTERED"); diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SqlParserTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SqlParserTest.java index 38eefaaec1..a81e4f4dfd 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SqlParserTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SqlParserTest.java @@ -62,7 +62,7 @@ public void init() { parser = new SqlParser(); } - @Rule public ExpectedException thrown = ExpectedException.none(); + @Rule public final ExpectedException thrown = ExpectedException.none(); @Test public void whereConditionLeftFunctionRightPropertyGreatTest() throws Exception { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SubQueryParserTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SubQueryParserTest.java index 5713179b46..81e084e152 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SubQueryParserTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/parser/SubQueryParserTest.java @@ -19,7 +19,7 @@ public class SubQueryParserTest { - private static SqlParser parser = new SqlParser(); + private static final SqlParser parser = new SqlParser(); @Test public void selectFromSubqueryShouldPass() throws SqlParseException { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerBatchTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerBatchTest.java index 0c77550a2f..bb3a960270 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerBatchTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerBatchTest.java @@ -43,7 +43,7 @@ public class QueryPlannerBatchTest extends QueryPlannerTest { private static final String TEST_SQL3 = "ON d.id = e.departmentId " + " WHERE e.age <= 50"; - private SearchHit[] employees = { + private final SearchHit[] employees = { employee(1, "People 1", "A"), employee(2, "People 2", "A"), employee(3, "People 3", "A"), @@ -56,7 +56,7 @@ public class QueryPlannerBatchTest extends QueryPlannerTest { employee(10, "People 10", "F") }; - private SearchHit[] departments = { + private final SearchHit[] departments = { department(1, "A", "AWS"), department(2, "C", "Capital One"), department(3, "D", "Dell"), @@ -66,7 +66,7 @@ public class QueryPlannerBatchTest extends QueryPlannerTest { department(7, "U", "Uber"), }; - private Matcher[] matched = { + private final Matcher[] matched = { hit(kv("name", "People 1"), kv("id", "A"), kv("dep", "AWS")), hit(kv("name", "People 2"), kv("id", "A"), kv("dep", "AWS")), hit(kv("name", "People 3"), kv("id", "A"), kv("dep", "AWS")), @@ -76,25 +76,27 @@ public class QueryPlannerBatchTest extends QueryPlannerTest { hit(kv("name", "People 10"), kv("id", "F"), kv("dep", "Facebook")) }; - private Matcher[] mismatched1 = { + private final Matcher[] mismatched1 = { hit(kv("name", null), kv("id", "G"), kv("dep", "Google")), hit(kv("name", null), kv("id", "M"), kv("dep", "Microsoft")), hit(kv("name", null), kv("id", "U"), kv("dep", "Uber")) }; - private Matcher[] mismatched2 = { + private final Matcher[] mismatched2 = { hit(kv("name", "People 4"), kv("id", null), kv("dep", null)), hit(kv("name", "People 5"), kv("id", null), kv("dep", null)), hit(kv("name", "People 9"), kv("id", null), kv("dep", null)) }; - private Matcher expectedInnerJoinResult = hits(matched); + private final Matcher expectedInnerJoinResult = hits(matched); /** Department left join Employee */ - private Matcher expectedLeftOuterJoinResult1 = hits(concat(matched, mismatched1)); + private final Matcher expectedLeftOuterJoinResult1 = + hits(concat(matched, mismatched1)); /** Employee left join Department */ - private Matcher expectedLeftOuterJoinResult2 = hits(concat(matched, mismatched2)); + private final Matcher expectedLeftOuterJoinResult2 = + hits(concat(matched, mismatched2)); /** Parameterized test cases */ private final int blockSize; diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerMonitorTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerMonitorTest.java index 9b1d307ebc..6995743d06 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerMonitorTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/QueryPlannerMonitorTest.java @@ -34,7 +34,7 @@ public class QueryPlannerMonitorTest extends QueryPlannerTest { private static final long[] PERCENT_USAGE_24 = freeAndTotalMem(76, 100); private static final long[] PERCENT_USAGE_50 = freeAndTotalMem(50, 100); - @Spy private Stats stats = new Stats(client); + @Spy private final Stats stats = new Stats(client); @Test public void reachedLimitAndRecoverAt1stAttempt() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLAggregationParserTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLAggregationParserTest.java index d6911ac2fc..6b93dbcaf4 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLAggregationParserTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLAggregationParserTest.java @@ -35,7 +35,7 @@ @RunWith(MockitoJUnitRunner.class) public class SQLAggregationParserTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void parseAggWithoutExpressionShouldPass() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLExprToExpressionConverterTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLExprToExpressionConverterTest.java index ac949eb0d7..100b5ebe47 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLExprToExpressionConverterTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/planner/converter/SQLExprToExpressionConverterTest.java @@ -33,7 +33,7 @@ @RunWith(MockitoJUnitRunner.class) public class SQLExprToExpressionConverterTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); private SQLExprToExpressionConverter converter; private SQLAggregationParser.Context context; diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/identifier/UnquoteIdentifierRuleTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/identifier/UnquoteIdentifierRuleTest.java index 30bbac861a..5a27420b12 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/identifier/UnquoteIdentifierRuleTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/identifier/UnquoteIdentifierRuleTest.java @@ -65,8 +65,8 @@ private QueryAssertion query(String sql) { private static class QueryAssertion { - private UnquoteIdentifierRule rule = new UnquoteIdentifierRule(); - private SQLQueryExpr expr; + private final UnquoteIdentifierRule rule = new UnquoteIdentifierRule(); + private final SQLQueryExpr expr; QueryAssertion(String sql) { this.expr = SqlParserUtils.parse(sql); diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/ordinal/OrdinalRewriterRuleTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/ordinal/OrdinalRewriterRuleTest.java index d27967e361..d4bbc59eb5 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/ordinal/OrdinalRewriterRuleTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/ordinal/OrdinalRewriterRuleTest.java @@ -18,7 +18,7 @@ /** Test cases for ordinal aliases in GROUP BY and ORDER BY */ public class OrdinalRewriterRuleTest { - @Rule public ExpectedException exception = ExpectedException.none(); + @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void ordinalInGroupByShouldMatch() { @@ -118,8 +118,8 @@ private QueryAssertion query(String sql) { private static class QueryAssertion { - private OrdinalRewriterRule rule; - private SQLQueryExpr expr; + private final OrdinalRewriterRule rule; + private final SQLQueryExpr expr; QueryAssertion(String sql) { this.expr = SqlParserUtils.parse(sql); diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/parent/SQLExprParentSetterRuleTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/parent/SQLExprParentSetterRuleTest.java index 460b045ca0..3940ba1366 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/parent/SQLExprParentSetterRuleTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/parent/SQLExprParentSetterRuleTest.java @@ -19,7 +19,7 @@ public class SQLExprParentSetterRuleTest { @Mock private SQLQueryExpr queryExpr; - private SQLExprParentSetterRule rule = new SQLExprParentSetterRule(); + private final SQLExprParentSetterRule rule = new SQLExprParentSetterRule(); @Test public void match() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/ExistsSubQueryRewriterTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/ExistsSubQueryRewriterTest.java index dd15fd6683..e60eead33b 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/ExistsSubQueryRewriterTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/ExistsSubQueryRewriterTest.java @@ -13,7 +13,7 @@ public class ExistsSubQueryRewriterTest extends SubQueryRewriterTestBase { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void nonCorrelatedExists() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/InSubqueryRewriterTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/InSubqueryRewriterTest.java index bb33baae7d..95d236460e 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/InSubqueryRewriterTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/InSubqueryRewriterTest.java @@ -13,7 +13,7 @@ public class InSubqueryRewriterTest extends SubQueryRewriterTestBase { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void nonCorrleatedIn() throws Exception { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/SubQueryRewriteRuleTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/SubQueryRewriteRuleTest.java index 7bd3dd847e..0e0a30ef3a 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/SubQueryRewriteRuleTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/subquery/SubQueryRewriteRuleTest.java @@ -19,7 +19,7 @@ public class SubQueryRewriteRuleTest { final SubQueryRewriteRule rewriteRule = new SubQueryRewriteRule(); - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void isInMatch() throws SQLFeatureNotSupportedException { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/term/TermFieldRewriterTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/term/TermFieldRewriterTest.java index 7922d60647..561cafab81 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/term/TermFieldRewriterTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/rewriter/term/TermFieldRewriterTest.java @@ -21,7 +21,7 @@ import org.opensearch.sql.legacy.util.SqlParserUtils; public class TermFieldRewriterTest { - @Rule public ExpectedException exception = ExpectedException.none(); + @Rule public final ExpectedException exception = ExpectedException.none(); @Before public void setup() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java index 9fc2b6012d..983f10023e 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/utils/SQLFunctionsTest.java @@ -34,7 +34,7 @@ public class SQLFunctionsTest { - private SQLFunctions sqlFunctions = new SQLFunctions(); + private final SQLFunctions sqlFunctions = new SQLFunctions(); @Rule public ExpectedException exceptionRule = ExpectedException.none(); diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/util/MultipleIndexClusterUtils.java b/legacy/src/test/java/org/opensearch/sql/legacy/util/MultipleIndexClusterUtils.java index 8890a6853f..85b8cffb59 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/util/MultipleIndexClusterUtils.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/util/MultipleIndexClusterUtils.java @@ -33,7 +33,7 @@ public class MultipleIndexClusterUtils { public static final String INDEX_ACCOUNT_2 = "account2"; public static final String INDEX_ACCOUNT_ALL = "account*"; - public static String INDEX_ACCOUNT_1_MAPPING = + public static final String INDEX_ACCOUNT_1_MAPPING = "{\n" + " \"field_mappings\": {\n" + " \"mappings\": {\n" @@ -93,7 +93,7 @@ public class MultipleIndexClusterUtils { * The difference with account1. 1. missing address. 2. age has different type. 3. * projects.started_year has different type. */ - public static String INDEX_ACCOUNT_2_MAPPING = + public static final String INDEX_ACCOUNT_2_MAPPING = "{\n" + " \"field_mappings\": {\n" + " \"mappings\": {\n" diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/response/error/ErrorMessage.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/response/error/ErrorMessage.java index bbcacc1d2c..fbe6d3cd72 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/response/error/ErrorMessage.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/response/error/ErrorMessage.java @@ -12,7 +12,7 @@ /** Error Message. */ public class ErrorMessage { - protected Throwable exception; + protected final Throwable exception; private final int status; diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanQueryBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanQueryBuilder.java index f4b0b05256..08567b78c1 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanQueryBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanQueryBuilder.java @@ -42,7 +42,7 @@ @EqualsAndHashCode class OpenSearchIndexScanQueryBuilder implements PushDownQueryBuilder { - OpenSearchRequestBuilder requestBuilder; + final OpenSearchRequestBuilder requestBuilder; public OpenSearchIndexScanQueryBuilder(OpenSearchRequestBuilder requestBuilder) { this.requestBuilder = requestBuilder; diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/sort/SortQueryBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/sort/SortQueryBuilder.java index 7669b569d4..54e3477410 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/sort/SortQueryBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/sort/SortQueryBuilder.java @@ -25,14 +25,14 @@ public class SortQueryBuilder { /** The mapping between Core Engine sort order and OpenSearch sort order. */ - private Map sortOrderMap = + private final Map sortOrderMap = new ImmutableMap.Builder() .put(Sort.SortOrder.ASC, SortOrder.ASC) .put(Sort.SortOrder.DESC, SortOrder.DESC) .build(); /** The mapping between Core Engine null order and OpenSearch null order. */ - private Map missingMap = + private final Map missingMap = new ImmutableMap.Builder() .put(Sort.NullOrder.NULL_FIRST, "_first") .put(Sort.NullOrder.NULL_LAST, "_last") diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprGeoPointValueTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprGeoPointValueTest.java index defa97d8c8..1ff3321237 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprGeoPointValueTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/data/value/OpenSearchExprGeoPointValueTest.java @@ -14,7 +14,8 @@ class OpenSearchExprGeoPointValueTest { - private OpenSearchExprGeoPointValue geoPointValue = new OpenSearchExprGeoPointValue(1.0, 1.0); + private final OpenSearchExprGeoPointValue geoPointValue = + new OpenSearchExprGeoPointValue(1.0, 1.0); @Test void value() { diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java index 0a3f56285f..fa328fd26c 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/planner/physical/MLOperatorTest.java @@ -65,7 +65,7 @@ public class MLOperatorTest { private NodeClient nodeClient; private MLOperator mlOperator; - Map arguments = new HashMap<>(); + final Map arguments = new HashMap<>(); @Mock(answer = Answers.RETURNS_DEEP_STUBS) private MachineLearningNodeClient machineLearningNodeClient; diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/response/OpenSearchResponseTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/response/OpenSearchResponseTest.java index 217145a052..984c98f803 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/response/OpenSearchResponseTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/response/OpenSearchResponseTest.java @@ -60,14 +60,14 @@ class OpenSearchResponseTest { @Mock private Aggregations aggregations; - private List includes = List.of(); + private final List includes = List.of(); @Mock private OpenSearchAggregationResponseParser parser; - private ExprTupleValue exprTupleValue1 = + private final ExprTupleValue exprTupleValue1 = ExprTupleValue.fromExprValueMap(ImmutableMap.of("id1", new ExprIntegerValue(1))); - private ExprTupleValue exprTupleValue2 = + private final ExprTupleValue exprTupleValue2 = ExprTupleValue.fromExprValueMap(ImmutableMap.of("id2", new ExprIntegerValue(2))); @Test diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/response/error/ErrorMessageFactoryTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/response/error/ErrorMessageFactoryTest.java index eb759233a8..6ffe6b275c 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/response/error/ErrorMessageFactoryTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/response/error/ErrorMessageFactoryTest.java @@ -13,8 +13,8 @@ import org.opensearch.core.rest.RestStatus; public class ErrorMessageFactoryTest { - private Throwable nonOpenSearchThrowable = new Throwable(); - private Throwable openSearchThrowable = new OpenSearchException(nonOpenSearchThrowable); + private final Throwable nonOpenSearchThrowable = new Throwable(); + private final Throwable openSearchThrowable = new OpenSearchException(nonOpenSearchThrowable); @Test public void openSearchExceptionShouldCreateEsErrorMessage() { diff --git a/plugin/src/test/java/org/opensearch/sql/plugin/transport/TransportPPLQueryRequestTest.java b/plugin/src/test/java/org/opensearch/sql/plugin/transport/TransportPPLQueryRequestTest.java index 286ac20fed..1cce1ccc18 100644 --- a/plugin/src/test/java/org/opensearch/sql/plugin/transport/TransportPPLQueryRequestTest.java +++ b/plugin/src/test/java/org/opensearch/sql/plugin/transport/TransportPPLQueryRequestTest.java @@ -20,7 +20,7 @@ public class TransportPPLQueryRequestTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void testValidate() { diff --git a/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java b/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java index aec22ac231..98c41027ff 100644 --- a/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java +++ b/ppl/src/main/java/org/opensearch/sql/ppl/parser/AstExpressionBuilder.java @@ -63,7 +63,7 @@ public class AstExpressionBuilder extends OpenSearchPPLParserBaseVisitor FUNCTION_NAME_MAPPING = + private static final Map FUNCTION_NAME_MAPPING = new ImmutableMap.Builder() .put("isnull", IS_NULL.getName().getFunctionName()) .put("isnotnull", IS_NOT_NULL.getName().getFunctionName()) diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/PPLServiceTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/PPLServiceTest.java index 598f6691cb..34553823c4 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/PPLServiceTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/PPLServiceTest.java @@ -32,9 +32,9 @@ @RunWith(MockitoJUnitRunner.class) public class PPLServiceTest { - private static String QUERY = "/_plugins/_ppl"; + private static final String QUERY = "/_plugins/_ppl"; - private static String EXPLAIN = "/_plugins/_ppl/_explain"; + private static final String EXPLAIN = "/_plugins/_ppl/_explain"; private PPLService pplService; diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java index 5601bda485..2645be3aca 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/antlr/PPLSyntaxParserTest.java @@ -18,7 +18,7 @@ public class PPLSyntaxParserTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void testSearchCommandShouldPass() { diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/domain/PPLQueryRequestTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/domain/PPLQueryRequestTest.java index 29e6ff3298..f4e90395cb 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/domain/PPLQueryRequestTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/domain/PPLQueryRequestTest.java @@ -15,7 +15,7 @@ public class PPLQueryRequestTest { - @Rule public ExpectedException exceptionRule = ExpectedException.none(); + @Rule public final ExpectedException exceptionRule = ExpectedException.none(); @Test public void getRequestShouldPass() { diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java index 488cb7dc14..ac2bce9dbc 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstBuilderTest.java @@ -66,7 +66,7 @@ public class AstBuilderTest { @Rule public ExpectedException exceptionRule = ExpectedException.none(); - private PPLSyntaxParser parser = new PPLSyntaxParser(); + private final PPLSyntaxParser parser = new PPLSyntaxParser(); @Test public void testSearchCommand() { diff --git a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstStatementBuilderTest.java b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstStatementBuilderTest.java index 7d7b31e822..0b98ee6179 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstStatementBuilderTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/parser/AstStatementBuilderTest.java @@ -30,7 +30,7 @@ public class AstStatementBuilderTest { @Rule public ExpectedException exceptionRule = ExpectedException.none(); - private PPLSyntaxParser parser = new PPLSyntaxParser(); + private final PPLSyntaxParser parser = new PPLSyntaxParser(); @Test public void buildQueryStatement() { diff --git a/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java b/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java index e03169e9f8..fc3402e20a 100644 --- a/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java +++ b/protocol/src/test/java/org/opensearch/sql/protocol/response/QueryResultTest.java @@ -22,7 +22,7 @@ class QueryResultTest { - private ExecutionEngine.Schema schema = + private final ExecutionEngine.Schema schema = new ExecutionEngine.Schema( ImmutableList.of( new ExecutionEngine.Schema.Column("name", null, STRING), diff --git a/spark/src/main/java/org/opensearch/sql/spark/client/EmrClientImpl.java b/spark/src/main/java/org/opensearch/sql/spark/client/EmrClientImpl.java index 3ef911c8d8..7b7fa1eadf 100644 --- a/spark/src/main/java/org/opensearch/sql/spark/client/EmrClientImpl.java +++ b/spark/src/main/java/org/opensearch/sql/spark/client/EmrClientImpl.java @@ -34,7 +34,7 @@ public class EmrClientImpl implements SparkClient { private final FlintHelper flint; private final String sparkApplicationJar; private static final Logger logger = LogManager.getLogger(EmrClientImpl.class); - private SparkResponse sparkResponse; + private final SparkResponse sparkResponse; /** * Constructor for EMR Client Implementation. diff --git a/sql/src/test/java/org/opensearch/sql/sql/SQLServiceTest.java b/sql/src/test/java/org/opensearch/sql/sql/SQLServiceTest.java index b124757069..dc920b248f 100644 --- a/sql/src/test/java/org/opensearch/sql/sql/SQLServiceTest.java +++ b/sql/src/test/java/org/opensearch/sql/sql/SQLServiceTest.java @@ -36,9 +36,9 @@ @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) class SQLServiceTest { - private static String QUERY = "/_plugins/_sql"; + private static final String QUERY = "/_plugins/_sql"; - private static String EXPLAIN = "/_plugins/_sql/_explain"; + private static final String EXPLAIN = "/_plugins/_sql/_explain"; private SQLService sqlService;