From c070edf4c006be2f2aaeb35d509bef17f936c12f Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Tue, 8 Aug 2023 10:42:04 -0700 Subject: [PATCH 1/6] Fixing strings change from main OS repo. Signed-off-by: Mitchell Gale --- .../java/org/opensearch/sql/legacy/RestIntegTestCase.java | 2 +- .../query/planner/physical/node/join/BlockHashJoin.java | 2 +- .../legacy/query/planner/physical/node/scroll/Scroll.java | 2 +- .../legacy/plugin/RestSQLQueryActionCursorFallbackTest.java | 2 +- .../opensearch/sql/legacy/unittest/QueryFunctionsTest.java | 6 +----- .../opensearch/sql/plugin/rest/RestQuerySettingsAction.java | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java b/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java index 50440facb6..53c1ad7553 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java @@ -44,8 +44,8 @@ import org.junit.Before; import org.opensearch.client.Request; import org.opensearch.client.Response; -import org.opensearch.common.Strings; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.common.Strings; import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java index cfb6265e52..19c0ae41d2 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java @@ -16,8 +16,8 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import org.opensearch.common.Strings; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.Strings; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.sql.legacy.query.planner.core.ExecuteParams; import org.opensearch.sql.legacy.query.planner.physical.PhysicalOperator; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java index 840acb1b17..2d781d7c3d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java @@ -12,9 +12,9 @@ import org.opensearch.action.search.ClearScrollResponse; import org.opensearch.action.search.SearchResponse; import org.opensearch.client.Client; -import org.opensearch.common.Strings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.Strings; import org.opensearch.index.query.BoolQueryBuilder; import org.opensearch.index.query.QueryBuilder; import org.opensearch.search.SearchHit; diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java index 2afcdc93f4..5f16e4d77a 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java @@ -20,11 +20,11 @@ import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.opensearch.client.node.NodeClient; -import org.opensearch.common.Strings; import org.opensearch.common.inject.Injector; import org.opensearch.common.inject.ModulesBuilder; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.common.Strings; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java index 9c1328eaa8..4c69ad19c2 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java @@ -24,8 +24,8 @@ import org.junit.Test; import org.mockito.Mockito; import org.opensearch.client.Client; -import org.opensearch.common.Strings; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.common.Strings; import org.opensearch.index.query.AbstractQueryBuilder; import org.opensearch.index.query.MultiMatchQueryBuilder; import org.opensearch.search.builder.SearchSourceBuilder.ScriptField; @@ -298,10 +298,6 @@ private String query(String from, String... statements) { return explain(SELECT_ALL + " " + from + " " + String.join(" ", statements)); } - private String query(String sql) { - return explain(sql); - } - private Matcher contains(AbstractQueryBuilder queryBuilder) { return containsString(Strings.toString(XContentType.JSON, queryBuilder, false, false)); } diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java index 7b51b47503..04d53aed1e 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java @@ -17,9 +17,9 @@ import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.opensearch.client.Requests; import org.opensearch.client.node.NodeClient; -import org.opensearch.common.Strings; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.BaseRestHandler; From 4275d88dabe8abde6cf46b0c043d0a4c27cd4a54 Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Tue, 8 Aug 2023 11:39:08 -0700 Subject: [PATCH 2/6] Fixing issues. Signed-off-by: Mitchell Gale --- .../org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java index 827f968bde..a2d12ada87 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java @@ -8,7 +8,6 @@ import com.fasterxml.jackson.core.JsonFactory; import java.io.IOException; -import org.opensearch.common.Strings; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.json.JsonXContentParser; From ef5746ce602275e18e172a2fd22a809832a81406 Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Tue, 8 Aug 2023 13:23:12 -0700 Subject: [PATCH 3/6] Fixing changed syntax to toStirng. Signed-off-by: Mitchell Gale --- .../org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java | 4 +++- .../opensearch/sql/plugin/rest/RestQuerySettingsAction.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java index a2d12ada87..19cb4837e3 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java @@ -10,7 +10,9 @@ import java.io.IOException; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContentParser; +import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -36,7 +38,7 @@ public static String format(String jsonString) throws IOException { ){ contentBuilder.copyCurrentStructure(contentParser); } - return Strings.toString(contentBuilder); + return contentBuilder.toString(); } private JsonPrettyFormatter() { diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java index 04d53aed1e..a1c57b591f 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java @@ -109,7 +109,7 @@ private Settings getAndFilterSettings(Map source) { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.map(source); Settings.Builder settingsBuilder = Settings.builder() - .loadFromSource(Strings.toString(builder), builder.contentType()); + .loadFromSource(builder.toString(), builder.contentType()); settingsBuilder.keys().removeIf(key -> { for (String prefix : SETTINGS_PREFIX) { if (key.startsWith(prefix)) { From 47abe6e15cbb12cc5abd3d5c0eca0d26fba76b2d Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Tue, 8 Aug 2023 13:47:10 -0700 Subject: [PATCH 4/6] Fixing changed syntax to toStirng. Signed-off-by: Mitchell Gale --- .../test/java/org/opensearch/sql/legacy/RestIntegTestCase.java | 3 +-- .../org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java | 2 -- .../opensearch/sql/plugin/rest/RestQuerySettingsAction.java | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java b/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java index 53c1ad7553..dd48d82114 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java @@ -45,7 +45,6 @@ import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.core.common.Strings; import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; @@ -164,7 +163,7 @@ protected static void updateClusterSetting(String settingKey, Object value, bool .endObject() .endObject(); Request request = new Request("PUT", "_cluster/settings"); - request.setJsonEntity(Strings.toString(builder)); + request.setJsonEntity(builder.toString()); Response response = client().performRequest(request); Assert .assertEquals(RestStatus.OK, RestStatus.fromCode(response.getStatusLine().getStatusCode())); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java index 19cb4837e3..ecc86877ee 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java @@ -10,9 +10,7 @@ import java.io.IOException; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContentParser; -import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; diff --git a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java index a1c57b591f..b15b4dddd6 100644 --- a/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java +++ b/plugin/src/main/java/org/opensearch/sql/plugin/rest/RestQuerySettingsAction.java @@ -19,7 +19,6 @@ import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.core.common.Strings; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.rest.BaseRestHandler; From 62d35229bdc53eac997f3851ce00e8ec68b76c2d Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Tue, 8 Aug 2023 13:50:08 -0700 Subject: [PATCH 5/6] add tosttring fix to RestSQLQueryActionCursorFallbackTest Signed-off-by: Mitchell Gale --- .../legacy/plugin/RestSQLQueryActionCursorFallbackTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java index 5f16e4d77a..64e5d161b7 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java @@ -24,7 +24,6 @@ import org.opensearch.common.inject.ModulesBuilder; import org.opensearch.common.util.concurrent.ThreadContext; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.core.common.Strings; import org.opensearch.rest.BaseRestHandler; import org.opensearch.rest.RestChannel; import org.opensearch.rest.RestRequest; @@ -93,7 +92,7 @@ private static SQLQueryRequest createSqlQueryRequest(String query, Optional Date: Tue, 8 Aug 2023 14:42:09 -0700 Subject: [PATCH 6/6] added unused function Signed-off-by: Mitchell Gale --- .../opensearch/sql/legacy/unittest/QueryFunctionsTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java index 4c69ad19c2..0ebf89e296 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java @@ -298,6 +298,10 @@ private String query(String from, String... statements) { return explain(SELECT_ALL + " " + from + " " + String.join(" ", statements)); } + private String query(String sql) { + return explain(sql); + } + private Matcher contains(AbstractQueryBuilder queryBuilder) { return containsString(Strings.toString(XContentType.JSON, queryBuilder, false, false)); }