diff --git a/core/src/main/java/org/opensearch/sql/executor/CanPaginateVisitor.java b/core/src/main/java/org/opensearch/sql/executor/CanPaginateVisitor.java index c85bbf0cc8..e3f7c7ad60 100644 --- a/core/src/main/java/org/opensearch/sql/executor/CanPaginateVisitor.java +++ b/core/src/main/java/org/opensearch/sql/executor/CanPaginateVisitor.java @@ -5,17 +5,12 @@ package org.opensearch.sql.executor; +import java.util.concurrent.atomic.AtomicBoolean; import org.opensearch.sql.ast.AbstractNodeVisitor; import org.opensearch.sql.ast.Node; import org.opensearch.sql.ast.expression.AllFields; -import org.opensearch.sql.ast.tree.Filter; -import org.opensearch.sql.ast.tree.Limit; import org.opensearch.sql.ast.tree.Project; import org.opensearch.sql.ast.tree.Relation; -import org.opensearch.sql.ast.tree.Sort; -import org.opensearch.sql.ast.tree.Values; - -import java.util.concurrent.atomic.AtomicBoolean; /** * Use this unresolved plan visitor to check if a plan can be serialized by PaginatedPlanCache. diff --git a/core/src/main/java/org/opensearch/sql/executor/PaginatedPlanCache.java b/core/src/main/java/org/opensearch/sql/executor/PaginatedPlanCache.java index 73c058316c..49cd02dcf2 100644 --- a/core/src/main/java/org/opensearch/sql/executor/PaginatedPlanCache.java +++ b/core/src/main/java/org/opensearch/sql/executor/PaginatedPlanCache.java @@ -57,10 +57,15 @@ public Cursor convertToCursor(PhysicalPlan plan) { } } + /** + * Compress serialized query plan. + * @param str string representing a query plan + * @return str compressed with gzip. + */ @SneakyThrows public static String compress(String str) { if (str == null || str.length() == 0) { - return null; + return null; } ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -70,10 +75,15 @@ public static String compress(String str) { return HashCode.fromBytes(out.toByteArray()).toString(); } + /** + * Decompresses a query plan that was compress with {@link PaginatedPlanCache.compress}. + * @param input compressed query plan + * @return seria + */ @SneakyThrows public static String decompress(String input) { if (input == null || input.length() == 0) { - return null; + return null; } GZIPInputStream gzip = new GZIPInputStream(new ByteArrayInputStream( HashCode.fromString(input).asBytes())); @@ -114,10 +124,10 @@ public PhysicalPlan convertToPlan(String cursor) { throw new UnsupportedOperationException("Unsupported cursor"); } cursor = cursor.substring(cursor.indexOf(',') + 1); - int currentPageIndex = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10); + final int currentPageIndex = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10); cursor = cursor.substring(cursor.indexOf(',') + 1); - int pageSize = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10); + final int pageSize = Integer.parseInt(cursor, 0, cursor.indexOf(','), 10); cursor = cursor.substring(cursor.indexOf(',') + 1); if (!cursor.startsWith("(Project,")) { diff --git a/core/src/main/java/org/opensearch/sql/planner/optimizer/rule/PushPageSize.java b/core/src/main/java/org/opensearch/sql/planner/optimizer/rule/PushPageSize.java index 78f856535f..95cd23d6ca 100644 --- a/core/src/main/java/org/opensearch/sql/planner/optimizer/rule/PushPageSize.java +++ b/core/src/main/java/org/opensearch/sql/planner/optimizer/rule/PushPageSize.java @@ -17,8 +17,6 @@ import org.opensearch.sql.planner.logical.LogicalRelation; import org.opensearch.sql.planner.optimizer.Rule; -import java.util.Objects; - public class PushPageSize implements Rule { /** Capture the table inside matched logical paginate operator. */ diff --git a/core/src/test/java/org/opensearch/sql/planner/physical/RemoveOperatorTest.java b/core/src/test/java/org/opensearch/sql/planner/physical/RemoveOperatorTest.java index bf046bf0a6..1cc7d5532f 100644 --- a/core/src/test/java/org/opensearch/sql/planner/physical/RemoveOperatorTest.java +++ b/core/src/test/java/org/opensearch/sql/planner/physical/RemoveOperatorTest.java @@ -117,8 +117,7 @@ public void invalid_to_retrieve_schema_from_remove() { IllegalStateException exception = assertThrows(IllegalStateException.class, () -> plan.schema()); assertEquals( - "[BUG] schema can been only applied to ProjectOperator, " - + "instead of RemoveOperator(input=inputPlan, removeList=[response, referer])", + "[BUG] schema can been only applied to ProjectOperator, instead of RemoveOperator", exception.getMessage()); } } diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java index ddc76f6ba2..b33b7fd9a3 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/ContinueScrollRequest.java @@ -5,6 +5,8 @@ package org.opensearch.sql.opensearch.storage; +import static org.opensearch.sql.opensearch.request.OpenSearchScrollRequest.DEFAULT_SCROLL_TIMEOUT; + import java.util.function.Consumer; import java.util.function.Function; import lombok.EqualsAndHashCode; @@ -18,8 +20,6 @@ import org.opensearch.sql.opensearch.request.OpenSearchRequest; import org.opensearch.sql.opensearch.response.OpenSearchResponse; -import static org.opensearch.sql.opensearch.request.OpenSearchScrollRequest.DEFAULT_SCROLL_TIMEOUT; - public class ContinueScrollRequest implements OpenSearchRequest { final String initialScrollId; diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java index 646b414183..fa4e4bf106 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/OpenSearchPagedIndexScan.java @@ -7,14 +7,11 @@ import java.util.Collections; import java.util.Iterator; -import java.util.List; - import lombok.EqualsAndHashCode; import lombok.ToString; import org.opensearch.sql.data.model.ExprValue; import org.opensearch.sql.opensearch.client.OpenSearchClient; import org.opensearch.sql.opensearch.request.OpenSearchRequest; -import org.opensearch.sql.opensearch.request.OpenSearchScrollRequest; import org.opensearch.sql.opensearch.response.OpenSearchResponse; import org.opensearch.sql.storage.TableScanOperator; diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/PagedRequestBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/PagedRequestBuilder.java index c138e32755..ae89a238a0 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/PagedRequestBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/PagedRequestBuilder.java @@ -10,5 +10,6 @@ public interface PagedRequestBuilder { OpenSearchRequest build(); + OpenSearchRequest.IndexName getIndexName(); } diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/SubsequentPageRequestBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/SubsequentPageRequestBuilder.java index dca63e8e99..89f8f71933 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/SubsequentPageRequestBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/SubsequentPageRequestBuilder.java @@ -5,20 +5,15 @@ package org.opensearch.sql.opensearch.storage; +import lombok.RequiredArgsConstructor; import org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory; import org.opensearch.sql.opensearch.request.OpenSearchRequest; +@RequiredArgsConstructor public class SubsequentPageRequestBuilder implements PagedRequestBuilder { - private OpenSearchRequest.IndexName indexName; + final OpenSearchRequest.IndexName indexName; final String scrollId; - private OpenSearchExprValueFactory exprValueFactory; - - public SubsequentPageRequestBuilder(OpenSearchRequest.IndexName indexName, String scanAsString, - OpenSearchExprValueFactory exprValueFactory) { - this.indexName = indexName; - scrollId = scanAsString; - this.exprValueFactory = exprValueFactory; - } + final OpenSearchExprValueFactory exprValueFactory; @Override public OpenSearchRequest build() { diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanAggregationBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanAggregationBuilder.java index 719ef52b79..4e1b20db6e 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanAggregationBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/scan/OpenSearchIndexScanAggregationBuilder.java @@ -15,10 +15,10 @@ import org.opensearch.sql.expression.NamedExpression; import org.opensearch.sql.expression.ReferenceExpression; import org.opensearch.sql.expression.aggregation.NamedAggregator; +import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer; import org.opensearch.sql.opensearch.response.agg.OpenSearchAggregationResponseParser; import org.opensearch.sql.opensearch.storage.OpenSearchIndexScan; import org.opensearch.sql.opensearch.storage.script.aggregation.AggregationQueryBuilder; -import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer; import org.opensearch.sql.planner.logical.LogicalAggregation; import org.opensearch.sql.planner.logical.LogicalSort; import org.opensearch.sql.storage.TableScanOperator; 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 a67ceeae9a..cb0940c410 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 @@ -20,10 +20,10 @@ import org.opensearch.sql.expression.ExpressionNodeVisitor; import org.opensearch.sql.expression.NamedExpression; import org.opensearch.sql.expression.ReferenceExpression; +import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer; import org.opensearch.sql.opensearch.storage.OpenSearchIndexScan; import org.opensearch.sql.opensearch.storage.script.filter.FilterQueryBuilder; import org.opensearch.sql.opensearch.storage.script.sort.SortQueryBuilder; -import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer; import org.opensearch.sql.planner.logical.LogicalFilter; import org.opensearch.sql.planner.logical.LogicalHighlight; import org.opensearch.sql.planner.logical.LogicalLimit; diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngine.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngine.java index a48da59180..9e8b47f6b0 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngine.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngine.java @@ -16,9 +16,9 @@ import org.opensearch.script.ScriptContext; import org.opensearch.script.ScriptEngine; import org.opensearch.sql.expression.Expression; +import org.opensearch.sql.expression.serialization.ExpressionSerializer; import org.opensearch.sql.opensearch.storage.script.aggregation.ExpressionAggregationScriptFactory; import org.opensearch.sql.opensearch.storage.script.filter.ExpressionFilterScriptFactory; -import org.opensearch.sql.expression.serialization.ExpressionSerializer; /** * Custom expression script engine that supports using core engine expression code in DSL diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java index f8ede598c1..14f38bd5f3 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/AggregationQueryBuilder.java @@ -30,13 +30,13 @@ import org.opensearch.sql.expression.NamedExpression; import org.opensearch.sql.expression.ReferenceExpression; import org.opensearch.sql.expression.aggregation.NamedAggregator; +import org.opensearch.sql.expression.serialization.ExpressionSerializer; import org.opensearch.sql.opensearch.response.agg.CompositeAggregationParser; import org.opensearch.sql.opensearch.response.agg.MetricParser; import org.opensearch.sql.opensearch.response.agg.NoBucketAggregationParser; import org.opensearch.sql.opensearch.response.agg.OpenSearchAggregationResponseParser; import org.opensearch.sql.opensearch.storage.script.aggregation.dsl.BucketAggregationBuilder; import org.opensearch.sql.opensearch.storage.script.aggregation.dsl.MetricAggregationBuilder; -import org.opensearch.sql.expression.serialization.ExpressionSerializer; /** * Build the AggregationBuilder from the list of {@link NamedAggregator} diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/AggregationBuilderHelper.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/AggregationBuilderHelper.java index 9cba3622a0..d9360276a0 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/AggregationBuilderHelper.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/AggregationBuilderHelper.java @@ -17,8 +17,8 @@ import org.opensearch.sql.expression.FunctionExpression; import org.opensearch.sql.expression.LiteralExpression; import org.opensearch.sql.expression.ReferenceExpression; -import org.opensearch.sql.opensearch.storage.script.ScriptUtils; import org.opensearch.sql.expression.serialization.ExpressionSerializer; +import org.opensearch.sql.opensearch.storage.script.ScriptUtils; /** * Abstract Aggregation Builder. diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilder.java index 6ccb308d6c..502b901441 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/BucketAggregationBuilder.java @@ -17,8 +17,8 @@ import org.opensearch.search.sort.SortOrder; import org.opensearch.sql.ast.expression.SpanUnit; import org.opensearch.sql.expression.NamedExpression; -import org.opensearch.sql.expression.span.SpanExpression; import org.opensearch.sql.expression.serialization.ExpressionSerializer; +import org.opensearch.sql.expression.span.SpanExpression; /** * Bucket Aggregation Builder. diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilder.java index d00a4eaf89..db8d1fdf1e 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/aggregation/dsl/MetricAggregationBuilder.java @@ -25,13 +25,13 @@ import org.opensearch.sql.expression.LiteralExpression; import org.opensearch.sql.expression.ReferenceExpression; import org.opensearch.sql.expression.aggregation.NamedAggregator; +import org.opensearch.sql.expression.serialization.ExpressionSerializer; import org.opensearch.sql.opensearch.response.agg.FilterParser; import org.opensearch.sql.opensearch.response.agg.MetricParser; import org.opensearch.sql.opensearch.response.agg.SingleValueParser; import org.opensearch.sql.opensearch.response.agg.StatsParser; import org.opensearch.sql.opensearch.response.agg.TopHitsParser; import org.opensearch.sql.opensearch.storage.script.filter.FilterQueryBuilder; -import org.opensearch.sql.expression.serialization.ExpressionSerializer; /** * Build the Metric Aggregation and List of {@link MetricParser} from {@link NamedAggregator}. diff --git a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilder.java b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilder.java index ff206a6a1e..a82869ec03 100644 --- a/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilder.java +++ b/opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilder.java @@ -24,6 +24,7 @@ import org.opensearch.sql.expression.FunctionExpression; import org.opensearch.sql.expression.function.BuiltinFunctionName; import org.opensearch.sql.expression.function.FunctionName; +import org.opensearch.sql.expression.serialization.ExpressionSerializer; import org.opensearch.sql.opensearch.storage.script.filter.lucene.LikeQuery; import org.opensearch.sql.opensearch.storage.script.filter.lucene.LuceneQuery; import org.opensearch.sql.opensearch.storage.script.filter.lucene.RangeQuery; @@ -38,7 +39,6 @@ import org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance.QueryStringQuery; import org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance.SimpleQueryStringQuery; import org.opensearch.sql.opensearch.storage.script.filter.lucene.relevance.WildcardQuery; -import org.opensearch.sql.expression.serialization.ExpressionSerializer; @RequiredArgsConstructor public class FilterQueryBuilder extends ExpressionNodeVisitor { diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/CursorTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/CursorTest.java index 6b2a1a7c57..6833eb8e88 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/CursorTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/CursorTest.java @@ -11,12 +11,12 @@ class CursorTest { @Test - void EmptyArrayIsNone() { + void emptyArrayIsNone() { Assertions.assertEquals(Cursor.None, new Cursor(new byte[]{})); } @Test - void ToStringIsArrayValue() { + void toStringIsArrayValue() { String cursorTxt = "This is a test"; Assertions.assertEquals(cursorTxt, new Cursor(cursorTxt.getBytes()).toString()); } diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/OpenSearchExecutionEngineTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/OpenSearchExecutionEngineTest.java index ff529a018f..7f01bc605b 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/OpenSearchExecutionEngineTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/executor/OpenSearchExecutionEngineTest.java @@ -36,10 +36,10 @@ import org.opensearch.sql.common.response.ResponseListener; import org.opensearch.sql.common.setting.Settings; import org.opensearch.sql.data.model.ExprValue; -import org.opensearch.sql.executor.PaginatedPlanCache; import org.opensearch.sql.executor.ExecutionContext; import org.opensearch.sql.executor.ExecutionEngine; import org.opensearch.sql.executor.ExecutionEngine.ExplainResponse; +import org.opensearch.sql.executor.PaginatedPlanCache; import org.opensearch.sql.opensearch.client.OpenSearchClient; import org.opensearch.sql.opensearch.data.value.OpenSearchExprValueFactory; import org.opensearch.sql.opensearch.executor.protector.OpenSearchExecutionProtector; diff --git a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngineTest.java b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngineTest.java index b106f396fb..a88d81c020 100644 --- a/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngineTest.java +++ b/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/ExpressionScriptEngineTest.java @@ -27,8 +27,8 @@ import org.opensearch.script.ScriptEngine; import org.opensearch.sql.expression.DSL; import org.opensearch.sql.expression.Expression; -import org.opensearch.sql.opensearch.storage.script.filter.ExpressionFilterScriptFactory; import org.opensearch.sql.expression.serialization.ExpressionSerializer; +import org.opensearch.sql.opensearch.storage.script.filter.ExpressionFilterScriptFactory; @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @ExtendWith(MockitoExtension.class) diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java b/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java index ae513dc206..c9f7cb9748 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/SQLPlugin.java @@ -57,6 +57,7 @@ import org.opensearch.sql.datasource.DataSourceServiceImpl; import org.opensearch.sql.datasource.model.DataSource; import org.opensearch.sql.datasource.model.DataSourceMetadata; +import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer; import org.opensearch.sql.legacy.esdomain.LocalClusterState; import org.opensearch.sql.legacy.executor.AsyncRestExecutor; import org.opensearch.sql.legacy.metrics.Metrics; @@ -68,7 +69,6 @@ import org.opensearch.sql.opensearch.setting.OpenSearchSettings; import org.opensearch.sql.opensearch.storage.OpenSearchDataSourceFactory; import org.opensearch.sql.opensearch.storage.script.ExpressionScriptEngine; -import org.opensearch.sql.expression.serialization.DefaultExpressionSerializer; import org.opensearch.sql.plugin.config.OpenSearchPluginModule; import org.opensearch.sql.plugin.datasource.DataSourceSettings; import org.opensearch.sql.plugin.rest.RestPPLQueryAction; 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 ecac53a9c1..774143a348 100644 --- a/ppl/src/test/java/org/opensearch/sql/ppl/PPLServiceTest.java +++ b/ppl/src/test/java/org/opensearch/sql/ppl/PPLServiceTest.java @@ -26,6 +26,7 @@ import org.opensearch.sql.executor.ExecutionEngine.QueryResponse; import org.opensearch.sql.executor.PaginatedPlanCache; import org.opensearch.sql.executor.QueryService; +import org.opensearch.sql.executor.execution.PaginatedQueryService; import org.opensearch.sql.executor.execution.QueryPlanFactory; import org.opensearch.sql.opensearch.executor.Cursor; import org.opensearch.sql.ppl.antlr.PPLSyntaxParser; @@ -45,6 +46,9 @@ public class PPLServiceTest { @Mock private QueryService queryService; + @Mock + private PaginatedQueryService paginatedQueryService; + @Mock private ExecutionEngine.Schema schema; @@ -59,7 +63,7 @@ public void setUp() { queryManager = DefaultQueryManager.defaultQueryManager(); pplService = new PPLService(new PPLSyntaxParser(), queryManager, - new QueryPlanFactory(queryService, paginatedPlanCache)); + new QueryPlanFactory(queryService, paginatedQueryService, paginatedPlanCache)); } @After 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 cdb0e37ee5..de74e4932f 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 @@ -39,7 +39,8 @@ public void buildQueryStatement() { "search source=t a=1", new Query( project( - filter(relation("t"), compare("=", field("a"), intLiteral(1))), AllFields.of()), 0)); + filter(relation("t"), compare("=", field("a"), + intLiteral(1))), AllFields.of()), 0)); } @Test diff --git a/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java b/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java index bd0db9e9a0..62db130fc2 100644 --- a/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java +++ b/sql/src/main/java/org/opensearch/sql/sql/domain/SQLQueryRequest.java @@ -65,11 +65,12 @@ public class SQLQueryRequest { private boolean sanitize = true; private String cursor = ""; + /** * Constructor of SQLQueryRequest that passes request params. */ - public SQLQueryRequest( - JSONObject jsonContent, String query, String path, Map params, String cursor) { + public SQLQueryRequest(JSONObject jsonContent, String query, String path, + Map params, String cursor) { this.jsonContent = jsonContent; this.query = query; this.path = path; @@ -77,7 +78,7 @@ public SQLQueryRequest( this.format = getFormat(params); this.sanitize = shouldSanitize(params); // TODO hack - this.cursor = cursor == null? "" : cursor; + this.cursor = cursor == null ? "" : cursor; } /** 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 9fcf1fa098..62718800b1 100644 --- a/sql/src/test/java/org/opensearch/sql/sql/SQLServiceTest.java +++ b/sql/src/test/java/org/opensearch/sql/sql/SQLServiceTest.java @@ -28,6 +28,7 @@ import org.opensearch.sql.executor.ExecutionEngine.ExplainResponseNode; import org.opensearch.sql.executor.PaginatedPlanCache; import org.opensearch.sql.executor.QueryService; +import org.opensearch.sql.executor.execution.PaginatedQueryService; import org.opensearch.sql.executor.execution.QueryPlanFactory; import org.opensearch.sql.opensearch.executor.Cursor; import org.opensearch.sql.sql.antlr.SQLSyntaxParser; @@ -47,6 +48,9 @@ class SQLServiceTest { @Mock private QueryService queryService; + @Mock + private PaginatedQueryService paginatedQueryService; + @Mock private ExecutionEngine.Schema schema; @@ -57,7 +61,7 @@ class SQLServiceTest { public void setUp() { queryManager = DefaultQueryManager.defaultQueryManager(); sqlService = new SQLService(new SQLSyntaxParser(), queryManager, - new QueryPlanFactory(queryService, paginatedPlanCache)); + new QueryPlanFactory(queryService, paginatedQueryService, paginatedPlanCache)); } @AfterEach