Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Update usage of Strings.toString #1404

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Map;
import java.util.Objects;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.sql.legacy.query.planner.core.ExecuteParams;
import org.opensearch.sql.legacy.query.planner.physical.PhysicalOperator;
Expand Down Expand Up @@ -97,7 +98,7 @@ private BoolQueryBuilder queryForPushedDownOnConds() {
);

if (LOG.isTraceEnabled()) {
LOG.trace("Terms filter optimization: {}", Strings.toString(andQuery));
LOG.trace("Terms filter optimization: {}", Strings.toString(XContentType.JSON, andQuery));
}
orQuery.should(andQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;

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.MediaType;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.search.SearchHit;
Expand Down Expand Up @@ -94,7 +97,7 @@ public void open(ExecuteParams params) throws Exception {
generateNewQueryWithExtraFilter((BoolQueryBuilder) filter));

if (LOG.isDebugEnabled()) {
LOG.debug("Received extra query filter, re-build query: {}", Strings.toString(
LOG.debug("Received extra query filter, re-build query: {}", Strings.toString(XContentType.JSON,
request.getRequestBuilder().request().source(), true, true
));
}
Expand Down Expand Up @@ -194,6 +197,6 @@ private String describeTable() {
*********************************************/

public String getRequest() {
return Strings.toString(request.getRequestBuilder().request().source());
return Strings.toString(XContentType.JSON, request.getRequestBuilder().request().source());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.mockito.Mockito;
import org.opensearch.client.Client;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.index.query.AbstractQueryBuilder;
import org.opensearch.index.query.MultiMatchQueryBuilder;
import org.opensearch.search.builder.SearchSourceBuilder.ScriptField;
Expand Down Expand Up @@ -302,6 +303,6 @@ private String query(String sql) {
}

private Matcher<String> contains(AbstractQueryBuilder queryBuilder) {
return containsString(Strings.toString(queryBuilder, false, false));
return containsString(Strings.toString(XContentType.JSON, queryBuilder, false, false));
}
}