From 810ffcc3fcdbc993bf943d165e2d2d93b0c5b6a7 Mon Sep 17 00:00:00 2001 From: Forest Vey <36905077+forestmvey@users.noreply.github.com> Date: Thu, 19 May 2022 12:42:19 -0700 Subject: [PATCH] Integ relevance function it fix (#608) Signed-off-by: forestmvey --- .../sql/legacy/AggregationExpressionIT.java | 4 ---- .../org/opensearch/sql/legacy/AggregationIT.java | 4 ---- .../org/opensearch/sql/legacy/DateFormatIT.java | 4 ---- .../org/opensearch/sql/legacy/JdbcTestIT.java | 4 ---- .../org/opensearch/sql/legacy/SQLFunctionsIT.java | 4 ---- .../opensearch/sql/legacy/SQLIntegTestCase.java | 4 ++++ .../org/opensearch/sql/legacy/SubqueryIT.java | 4 ---- .../opensearch/sql/legacy/TypeInformationIT.java | 5 ----- .../org/opensearch/sql/sql/ConditionalIT.java | 4 ---- .../opensearch/sql/sql/RelevanceFunctionIT.java | 15 ++++++++------- 10 files changed, 12 insertions(+), 40 deletions(-) diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationExpressionIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationExpressionIT.java index 2f4d8a5d0e..d4374dcbaf 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationExpressionIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationExpressionIT.java @@ -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")); - } } diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationIT.java index 82260b9f07..1d530efa5e 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/AggregationIT.java @@ -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")); - } } diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/DateFormatIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/DateFormatIT.java index 1fc4934f3c..a0b4b19898 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/DateFormatIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/DateFormatIT.java @@ -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")); - } } diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/JdbcTestIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/JdbcTestIT.java index 3076d1d50e..74f999f368 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/JdbcTestIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/JdbcTestIT.java @@ -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( diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/SQLFunctionsIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/SQLFunctionsIT.java index a435787478..50fc93ee9b 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/SQLFunctionsIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/SQLFunctionsIT.java @@ -896,8 +896,4 @@ private void checkSuccessfulFieldCast(SearchHit[] hits, String field, String cas } } } - - private JSONObject executeJdbcRequest(String query) { - return new JSONObject(executeQuery(query, "jdbc")); - } } diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java b/integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java index 0c479cbd6e..2aaac32f5f 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java @@ -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; diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java index de73118a54..c9beeb8747 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/SubqueryIT.java @@ -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")); - } } diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/TypeInformationIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/TypeInformationIT.java index 1100103aee..01c8d33467 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/TypeInformationIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/TypeInformationIT.java @@ -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")); - } - } diff --git a/integ-test/src/test/java/org/opensearch/sql/sql/ConditionalIT.java b/integ-test/src/test/java/org/opensearch/sql/sql/ConditionalIT.java index 8b9753d86d..385341327d 100644 --- a/integ-test/src/test/java/org/opensearch/sql/sql/ConditionalIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/sql/ConditionalIT.java @@ -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")); - } } diff --git a/integ-test/src/test/java/org/opensearch/sql/sql/RelevanceFunctionIT.java b/integ-test/src/test/java/org/opensearch/sql/sql/RelevanceFunctionIT.java index dd8d79fbd7..d8a9571d2a 100644 --- a/integ-test/src/test/java/org/opensearch/sql/sql/RelevanceFunctionIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/sql/RelevanceFunctionIT.java @@ -5,6 +5,7 @@ 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; @@ -12,26 +13,26 @@ 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")); }