Skip to content

Commit

Permalink
Integ relevance function it fix (#608)
Browse files Browse the repository at this point in the history
Signed-off-by: forestmvey <[email protected]>
  • Loading branch information
forestmvey authored May 19, 2022
1 parent 13c38d5 commit 810ffcc
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,4 @@ public void aggregateCastStatementShouldNotReturnZero() {
verifySchema(response, schema("SUM(CAST(male AS INT))", "male_sum", "integer"));
verifyDataRows(response, rows(4));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1355,8 +1355,4 @@ private double getDoubleAggregationValue(final JSONObject queryResult,

return targetField.getDouble(subFieldName);
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,4 @@ public static String getScriptAggregationKey(JSONObject aggregation, String pref
.orElseThrow(() -> new RuntimeException(
"Can't find key" + prefix + " in aggregation " + aggregation));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ public void testGroupByInQuery() {
assertThat(response.getJSONArray("datarows").length(), equalTo(8));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}

@Test
public void numberOperatorNameCaseInsensitiveTest() {
assertSchemaContains(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,4 @@ private void checkSuccessfulFieldCast(SearchHit[] hits, String field, String cas
}
}
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ protected String executeQuery(String query, String requestType) {
}
}

protected JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}

protected String executeFetchQuery(String query, int fetchSize, String requestType)
throws IOException {
String endpoint = "/_plugins/_sql?format=" + requestType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,4 @@ public void selectFromSubqueryWithoutAliasShouldPass() throws IOException {
verifyDataRows(response,
rows("Lynn", "Pollard", 40));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,4 @@ public void testYearWithKeywordReturnsText() {

verifySchema(response, schema("YEAR(insert_time)", null, "integer"));
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,4 @@ private SearchHits query(String query) throws IOException {
rsp);
return SearchResponse.fromXContent(parser).getHits();
}

private JSONObject executeJdbcRequest(String query) {
return new JSONObject(executeQuery(query, "jdbc"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@

package org.opensearch.sql.sql;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_ACCOUNT;
import static org.opensearch.sql.util.MatcherUtils.rows;
import static org.opensearch.sql.util.MatcherUtils.schema;
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows;
import static org.opensearch.sql.util.MatcherUtils.verifySchema;

import java.io.IOException;
import org.json.JSONObject;
import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.opensearch.sql.legacy.SQLIntegTestCase;

public class RelevanceFunctionIT extends SQLIntegTestCase {
@Override
public void init() throws IOException {
loadIndex(Index.BANK);
loadIndex(Index.ACCOUNT);
}

@Test
void match_in_where() throws IOException {
JSONObject result = executeQuery("SELECT firstname WHERE match(lastname, 'Bates')");
public void match_in_where() throws IOException {
JSONObject result = executeJdbcRequest("SELECT firstname FROM " + TEST_INDEX_ACCOUNT + " WHERE match(lastname, 'Bates')");
verifySchema(result, schema("firstname", "text"));
verifyDataRows(result, rows("Nanette"));
}

@Test
void match_in_having() throws IOException {
JSONObject result = executeQuery("SELECT lastname HAVING match(firstname, 'Nanette')");
verifySchema(result, schema("lastname", "keyword"));
public void match_in_having() throws IOException {
JSONObject result = executeJdbcRequest("SELECT lastname FROM " + TEST_INDEX_ACCOUNT + " HAVING match(firstname, 'Nanette')");
verifySchema(result, schema("lastname", "text"));
verifyDataRows(result, rows("Bates"));
}

Expand Down

0 comments on commit 810ffcc

Please sign in to comment.