Skip to content

Commit ae7e692

Browse files
correct exception
Signed-off-by: Aparajita Pandey <aparajita31pandey@gmail.com>
1 parent 3558324 commit ae7e692

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
package org.opensearch.sql.sql;
77

88
import static org.opensearch.sql.legacy.TestUtils.getResponseBody;
9-
import static org.opensearch.sql.legacy.TestsConstants.*;
9+
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_CALCS;
10+
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ONLINE;
1011

1112
import java.io.IOException;
1213
import lombok.SneakyThrows;
@@ -256,22 +257,24 @@ public void testAlias() throws Exception {
256257
public void testAliasResultConsistency() throws Exception {
257258
String aliasName = "alias_dog_consistency";
258259

259-
// Create an alias for 2 index(dog1, dog2)
260+
// Create an alias that maps to both DOG and DOGS2 indices
260261
String createAliasQuery =
261262
String.format(
262-
"{ \"actions\": [ { \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } }, "
263-
+ "{\"add\": { \"index\": \"%s\", \"alias\": \"%s\" } } ] }",
263+
"{ \"actions\": [ "
264+
+ "{ \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } }, "
265+
+ "{ \"add\": { \"index\": \"%s\", \"alias\": \"%s\" } } "
266+
+ "] }",
264267
Index.DOG.getName(), aliasName, Index.DOGS2.getName(), aliasName);
265268
Request createAliasRequest = new Request("POST", "/_aliases");
266269
createAliasRequest.setJsonEntity(createAliasQuery);
267270
JSONObject aliasResponse = new JSONObject(executeRequest(createAliasRequest));
268271
assertTrue(aliasResponse.getBoolean("acknowledged"));
269272

270-
// Query using direct index
271-
String directQuery = String.format("SELECT * FROM %s", TEST_INDEX_DOG);
273+
// Query both indices directly (same indices the alias points to)
274+
String directQuery = String.format("SELECT * FROM %s, %s", Index.DOG.getName(), Index.DOGS2.getName());
272275
JSONObject directResponse = new JSONObject(executeFetchQuery(directQuery, 10, "jdbc"));
273276

274-
// Query using alias
277+
// Query using alias (which points to the same two indices)
275278
String aliasQuery = String.format("SELECT * FROM %s", aliasName);
276279
JSONObject aliasQueryResponse = new JSONObject(executeFetchQuery(aliasQuery, 10, "jdbc"));
277280

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
@@ -175,7 +175,7 @@ private void loadFromEsState(Query query) {
175175
Map<String, Map<String, FieldMappingMetadata>> mappings = response.mappings();
176176
if (mappings.isEmpty()) {
177177
throw new IllegalArgumentException(
178-
String.format(String.format("Index type %s does not exist", query.getFrom())));
178+
String.format("Index type %s does not exist", query.getFrom()));
179179
}
180180
Map<String, FieldMappingMetadata> typeMappings = mappings.values().iterator().next();
181181

0 commit comments

Comments
 (0)