Skip to content

Commit f6cbacd

Browse files
SpotlessCheck Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
1 parent e81ceba commit f6cbacd

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ protected String makeRequest(String query, int fetch_size) {
463463
}
464464

465465
protected String makeRequest(String query, int fetch_size, String filterQuery) {
466-
return String.format("{ \"fetch_size\": \"%s\", \"query\": \"%s\", \"filter\" : %s }", fetch_size, query, filterQuery);
466+
return String.format(
467+
"{ \"fetch_size\": \"%s\", \"query\": \"%s\", \"filter\" : %s }",
468+
fetch_size, query, filterQuery);
467469
}
468470

469471
protected String makeFetchLessRequest(String query) {

integ-test/src/test/java/org/opensearch/sql/sql/PaginationIT.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import org.junit.Ignore;
1919
import org.junit.Test;
2020
import org.opensearch.client.Request;
21-
import org.opensearch.client.Response;
2221
import org.opensearch.client.RequestOptions;
22+
import org.opensearch.client.Response;
2323
import org.opensearch.client.ResponseException;
2424
import org.opensearch.sql.common.setting.Settings;
2525
import org.opensearch.sql.legacy.SQLIntegTestCase;
@@ -217,42 +217,44 @@ public void testQueryWithoutFrom() {
217217
assertEquals(1, response.getInt("total"));
218218
assertEquals(1, response.getJSONArray("datarows").getJSONArray(0).getInt(0));
219219
}
220+
220221
@Test
221222
public void testAlias() throws Exception {
222223
String indexName = Index.ONLINE.getName();
223224
String aliasName = "alias_ONLINE";
224-
String filterQuery = "{\n" +
225-
" \"term\": {\n" +
226-
" \"107\": 72 \n" +
227-
" }\n" +
228-
"}";
225+
String filterQuery = "{\n" + " \"term\": {\n" + " \"107\": 72 \n" + " }\n" + "}";
229226

230-
//Execute the SQL query with filter
227+
// Execute the SQL query with filter
231228
String selectQuery = "SELECT * FROM " + TEST_INDEX_ONLINE;
232-
JSONObject initialResponse = new JSONObject(executeFetchQuery(selectQuery, 10, "jdbc", filterQuery));
229+
JSONObject initialResponse =
230+
new JSONObject(executeFetchQuery(selectQuery, 10, "jdbc", filterQuery));
233231
assertEquals(initialResponse.getInt("size"), 10);
234232

235-
//Create an alias
236-
String createAliasQuery = String.format("{ \"actions\": [ { \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } } ] }", indexName, aliasName);
233+
// Create an alias
234+
String createAliasQuery =
235+
String.format(
236+
"{ \"actions\": [ { \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } } ] }",
237+
indexName, aliasName);
237238
Request createAliasRequest = new Request("POST", "/_aliases");
238239
createAliasRequest.setJsonEntity(createAliasQuery);
239240
JSONObject aliasResponse = new JSONObject(executeRequest(createAliasRequest));
240241

241242
// Assert that alias creation was acknowledged
242243
assertTrue(aliasResponse.getBoolean("acknowledged"));
243244

244-
//Query using the alias
245+
// Query using the alias
245246
String aliasSelectQuery = String.format("SELECT * FROM %s", aliasName);
246247
JSONObject aliasQueryResponse = new JSONObject(executeFetchQuery(aliasSelectQuery, 4, "jdbc"));
247248
assertEquals(4, aliasQueryResponse.getInt("size"));
248249

249-
//Query using the alias with filter
250-
JSONObject aliasFilteredResponse = new JSONObject(executeFetchQuery(aliasSelectQuery, 4, "jdbc", filterQuery));
250+
// Query using the alias with filter
251+
JSONObject aliasFilteredResponse =
252+
new JSONObject(executeFetchQuery(aliasSelectQuery, 4, "jdbc", filterQuery));
251253
assertEquals(aliasFilteredResponse.getInt("size"), 4);
252254
}
253255

254-
255-
private String executeFetchQuery(String query, int fetchSize, String requestType, String filter) throws IOException{
256+
private String executeFetchQuery(String query, int fetchSize, String requestType, String filter)
257+
throws IOException {
256258
String endpoint = "/_plugins/_sql?format=" + requestType;
257259
String requestBody = makeRequest(query, fetchSize, filter);
258260

legacy/src/main/java/org/opensearch/sql/legacy/executor/format/SelectResultSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ private void loadFromEsState(Query query) {
167167
String indexName = fetchIndexName(query);
168168
String[] fieldNames = fetchFieldsAsArray(query);
169169
GetAliasesResponse getAliasesResponse =
170-
client.admin().indices().getAliases(new GetAliasesRequest(indexName)).actionGet();
170+
client.admin().indices().getAliases(new GetAliasesRequest(indexName)).actionGet();
171171
if (getAliasesResponse != null && !getAliasesResponse.getAliases().isEmpty()) {
172172
indexName = getAliasesResponse.getAliases().keySet().iterator().next();
173173
}

0 commit comments

Comments
 (0)