Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Co-authored-by: Guian Gumpac <guian.gumpac@improving.com>
Signed-off-by: Mitchell Gale <Mitchell.gale@improving.com>
  • Loading branch information
3 people authored Aug 16, 2023
1 parent 87d1fd6 commit d4413b3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testInsertData() throws IOException {
assertEquals("POST", actual.getMethod());
assertEquals("/test/_bulk?refresh=true", actual.getEndpoint());
assertEquals(
"{\"index\":{}}\n" + "{\"name\":\"John\"}\n" + "{\"index\":{}}\n" + "{\"name\":\"Hank\"}\n",
"{\"index\":{}}\n{\"name\":\"John\"}\n{\"index\":{}}\n{\"name\":\"Hank\"}\n",
getBody(actual));
}

Expand All @@ -81,7 +81,7 @@ public void testInsertNullData() throws IOException {
assertEquals("POST", actual.getMethod());
assertEquals("/test/_bulk?refresh=true", actual.getEndpoint());
assertEquals(
"{\"index\":{}}\n" + "{\"age\":30}\n" + "{\"index\":{}}\n" + "{\"name\":\"Hank\"}\n",
"{\"index\":{}}\n{\"age\":30}\n{\"index\":{}}\n{\"name\":\"Hank\"}\n",
getBody(actual));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public void orderByIsNull() throws IOException {
// Another equivalent syntax
assertThat(
explainQuery(
"SELECT * FROM opensearch-sql_test_index_order " + "ORDER BY id IS NULL, id DESC"),
"SELECT * FROM opensearch-sql_test_index_order ORDER BY id IS NULL, id DESC"),
equalTo(
explainQuery(
"SELECT * FROM opensearch-sql_test_index_order " + "ORDER BY id IS NULL DESC")));
"SELECT * FROM opensearch-sql_test_index_order ORDER BY id IS NULL DESC")));
}

@Test
Expand All @@ -100,7 +100,7 @@ public void orderByIsNotNull() throws IOException {
// Another equivalent syntax
assertThat(
explainQuery(
"SELECT id, name FROM opensearch-sql_test_index_order " + "ORDER BY name IS NOT NULL"),
"SELECT id, name FROM opensearch-sql_test_index_order ORDER BY name IS NOT NULL"),
equalTo(
explainQuery(
"SELECT id, name FROM opensearch-sql_test_index_order "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public void testSizeAndTotal() throws IOException {
executeQuery(
String.format(
Locale.ROOT,
"SELECT * " + "FROM %s " + "WHERE balance > 30000 " + "LIMIT 5",
"SELECT * FROM %s WHERE balance > 30000 LIMIT 5",
TestsConstants.TEST_INDEX_ACCOUNT));

JSONArray dataRows = getDataRows(response);
Expand Down Expand Up @@ -427,7 +427,7 @@ public void aggregationFunctionInHaving() throws IOException {
executeQuery(
String.format(
Locale.ROOT,
"SELECT gender " + "FROM %s " + "GROUP BY gender " + "HAVING count(*) > 500",
"SELECT gender FROM %s GROUP BY gender HAVING count(*) > 500",
TestsConstants.TEST_INDEX_ACCOUNT));

String ageSum = "gender";
Expand Down Expand Up @@ -549,7 +549,7 @@ public void joinQuerySelectOnlyOnOneTable() throws Exception {
executeQuery(
String.format(
Locale.ROOT,
"SELECT b1.age " + "FROM %s b1 JOIN %s b2 ON b1.firstname = b2.firstname",
"SELECT b1.age FROM %s b1 JOIN %s b2 ON b1.firstname = b2.firstname",
TestsConstants.TEST_INDEX_ACCOUNT,
TestsConstants.TEST_INDEX_ACCOUNT));

Expand Down Expand Up @@ -583,7 +583,7 @@ private void testFieldOrder(final String[] expectedFields, final Object[] expect
final String query =
String.format(
Locale.ROOT,
"SELECT %s FROM %s " + "WHERE email='amberduke@pyrami.com'",
"SELECT %s FROM %s WHERE email='amberduke@pyrami.com'",
fields,
TestsConstants.TEST_INDEX_ACCOUNT);
final JSONObject result = executeQuery(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,15 +813,15 @@ public void literal() throws Exception {

@Test
public void literalWithDoubleValue() throws Exception {
String query = "SELECT 10.0 " + "from " + TEST_INDEX_ACCOUNT + " limit 1";
String query = "SELECT 10.0 from " + TEST_INDEX_ACCOUNT + " limit 1";

final SearchHit[] hits = query(query).getHits();
assertThat(hits[0].getFields(), hasValue(contains(10.0)));
}

@Test
public void literalWithAlias() throws Exception {
String query = "SELECT 10 as key " + "from " + TEST_INDEX_ACCOUNT + " limit 1";
String query = "SELECT 10 as key from " + TEST_INDEX_ACCOUNT + " limit 1";
final SearchHit[] hits = query(query).getHits();

assertThat(hits.length, is(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ public static void dumpCoverage() {
}

/**
* As JUnit JavaDoc says: "The @AfterClass methods declared in superclasses will be run after
* those of the current class." So this method is supposed to run before closeClients() in parent
* As JUnit JavaDoc says:<br>
"The @AfterClass methods declared in superclasses will be run after those of the current class."<br>
So this method is supposed to run before closeClients() in parent class.
* class.
*/
@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void select_object_field() throws IOException {
JSONObject result =
executeQuery(
String.format(
"source=%s | " + "fields city.name, city.location.latitude",
"source=%s | fields city.name, city.location.latitude",
TEST_INDEX_DEEP_NESTED));
verifySchema(result, schema("city.name", "string"), schema("city.location.latitude", "double"));
verifyDataRows(result, rows("Seattle", 10.5));
Expand All @@ -51,7 +51,7 @@ public void compare_object_field_in_where() throws IOException {
public void group_object_field_in_stats() throws IOException {
JSONObject result =
executeQuery(
String.format("source=%s " + "| stats count() by city.name", TEST_INDEX_DEEP_NESTED));
String.format("source=%s | stats count() by city.name", TEST_INDEX_DEEP_NESTED));
verifySchema(result, schema("count()", "integer"), schema("city.name", "string"));
verifyDataRows(result, rows(1, "Seattle"));
}
Expand All @@ -61,7 +61,7 @@ public void sort_by_object_field() throws IOException {
JSONObject result =
executeQuery(
String.format(
"source=%s " + "| sort city.name" + "| fields city.name, city.location.latitude",
"source=%s | sort city.name | fields city.name, city.location.latitude",
TEST_INDEX_DEEP_NESTED));
verifySchema(result, schema("city.name", "string"), schema("city.location.latitude", "double"));
verifyDataRows(result, rows("Seattle", 10.5));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void unsupportedAggregationFunctionShouldFailSyntaxCheck() {
public void nonexistentFieldShouldFailSemanticCheck() {
String query = String.format("search source=%s | fields name", TEST_INDEX_ACCOUNT);
queryShouldThrowSemanticException(
query, "can't resolve Symbol(namespace=FIELD_NAME, " + "name=name) in type env");
query, "can't resolve Symbol(namespace=FIELD_NAME, name=name) in type env");
}

private void queryShouldPassSyntaxAndSemanticCheck(String query) {
Expand Down

0 comments on commit d4413b3

Please sign in to comment.