Skip to content

Commit

Permalink
Rework on integration tests. Add tests for PPL.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Jun 6, 2022
1 parent 2ac159f commit c1a91fc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.sql.ppl;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BEER;
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 static org.opensearch.sql.util.MatcherUtils.verifySome;

import java.io.IOException;
import org.junit.jupiter.api.Test;

public class RelevanceFunctionIT extends PPLIntegTestCase {
@Override
public void init() throws IOException {
loadIndex(Index.BEER);
}

@Test
public void test1() throws IOException {
String query = "SOURCE=" + TEST_INDEX_BEER
+ " | WHERE simple_query_string([\\\"Tags\\\" ^ 1.5, Title, `Body` 4.2], 'taste')";
var result = executeQuery(query);
//verifyDataRows(result, rows(32));

assertNotEquals(0, result.getInt("total"));
}

@Test
public void verify_wildcard_test() throws IOException {
String query1 = "SOURCE=" + TEST_INDEX_BEER
+ " | WHERE simple_query_string(['Tags'], 'taste')";
var result1 = executeQuery(query1);
String query2 = "SOURCE=" + TEST_INDEX_BEER
+ " | WHERE simple_query_string(['T*'], 'taste')";
var result2 = executeQuery(query2);
assertNotEquals(result2.getInt("total"), result1.getInt("total"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package org.opensearch.sql.sql;

import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_BEER;

import java.io.IOException;
import org.json.JSONObject;
import org.junit.jupiter.api.Test;
Expand All @@ -27,18 +29,18 @@ public void init() throws IOException {
@Test
public void test1() throws IOException {
String query = "SELECT count(*) FROM "
+ Index.BEER.getName() + " WHERE simple_query_string([\\\"Tags\\\" ^ 1.5, Title, `Body` 4.2], 'taste')";
+ TEST_INDEX_BEER + " WHERE simple_query_string([\\\"Tags\\\" ^ 1.5, Title, `Body` 4.2], 'taste')";
var result = new JSONObject(executeQuery(query, "jdbc"));
assertNotEquals(0, result.getInt("total"));
}

@Test
public void verify_wildcard_test() throws IOException {
String query1 = "SELECT count(*) FROM "
+ Index.BEER.getName() + " WHERE simple_query_string(['Tags'], 'taste')";
+ TEST_INDEX_BEER + " WHERE simple_query_string(['Tags'], 'taste')";
var result1 = new JSONObject(executeQuery(query1, "jdbc"));
String query2 = "SELECT count(*) FROM "
+ Index.BEER.getName() + " WHERE simple_query_string(['T*'], 'taste')";
+ TEST_INDEX_BEER + " WHERE simple_query_string(['T*'], 'taste')";
var result2 = new JSONObject(executeQuery(query2, "jdbc"));
assertNotEquals(result2.getInt("total"), result1.getInt("total"));
}
Expand Down

0 comments on commit c1a91fc

Please sign in to comment.