-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: MaxKsyunz <[email protected]> Co-authored-by: MaxKsyunz <[email protected]> Co-authored-by: Max Ksyunz <[email protected]>
- Loading branch information
1 parent
7cbb121
commit 86dcd51
Showing
32 changed files
with
627 additions
and
55 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
common/src/main/java/org/opensearch/sql/common/antlr/Parser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.opensearch.sql.common.antlr; | ||
|
||
import org.antlr.v4.runtime.tree.ParseTree; | ||
|
||
public interface Parser { | ||
ParseTree parse(String query); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
integ-test/src/test/java/org/opensearch/sql/ppl/MatchBoolPrefixIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.ppl; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_PHRASE; | ||
import static org.opensearch.sql.util.MatcherUtils.rows; | ||
import static org.opensearch.sql.util.MatcherUtils.verifyDataRows; | ||
|
||
import java.io.IOException; | ||
import org.json.JSONObject; | ||
import org.junit.Test; | ||
|
||
public class MatchBoolPrefixIT extends PPLIntegTestCase { | ||
|
||
@Override | ||
public void init() throws IOException { | ||
loadIndex(Index.PHRASE); | ||
} | ||
|
||
@Test | ||
public void valid_query_match_test() throws IOException { | ||
JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where match_bool_prefix(phrase, 'qui') | fields phrase", | ||
TEST_INDEX_PHRASE)); | ||
|
||
verifyDataRows(result, | ||
rows("quick fox"), | ||
rows("quick fox here")); | ||
} | ||
|
||
@Test | ||
public void optional_parameter_match_test() throws IOException { | ||
JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where match_bool_prefix(phrase, '2 tes', minimum_should_match=1, fuzziness=2) | fields phrase", | ||
TEST_INDEX_PHRASE)); | ||
|
||
verifyDataRows(result, | ||
rows("my test"), | ||
rows("my test 2")); | ||
} | ||
|
||
@Test | ||
public void no_matches_test() throws IOException { | ||
JSONObject result = | ||
executeQuery( | ||
String.format( | ||
"source=%s | where match_bool_prefix(phrase, 'rice') | fields phrase", | ||
TEST_INDEX_PHRASE)); | ||
|
||
assertEquals(0, result.getInt("total")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
integ-test/src/test/java/org/opensearch/sql/sql/MatchBoolPrefixIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.sql; | ||
|
||
import static org.opensearch.sql.legacy.TestsConstants.TEST_INDEX_PHRASE; | ||
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.Test; | ||
import org.opensearch.sql.legacy.SQLIntegTestCase; | ||
|
||
public class MatchBoolPrefixIT extends SQLIntegTestCase { | ||
public void init() throws IOException { | ||
loadIndex(SQLIntegTestCase.Index.PHRASE); | ||
} | ||
|
||
@Test | ||
public void query_matches_test() throws IOException { | ||
String query = "SELECT phrase FROM " | ||
+ TEST_INDEX_PHRASE + " WHERE match_bool_prefix(phrase, 'quick')"; | ||
var result = new JSONObject(executeQuery(query, "jdbc")); | ||
verifySchema(result, schema("phrase", "text")); | ||
|
||
verifyDataRows(result, | ||
rows("quick fox"), | ||
rows("quick fox here")); | ||
} | ||
|
||
@Test | ||
public void additional_parameters_test() throws IOException { | ||
String query = "SELECT phrase FROM " | ||
+ TEST_INDEX_PHRASE + " WHERE match_bool_prefix(phrase, '2 test', minimum_should_match=1, fuzziness=2)"; | ||
var result = new JSONObject(executeQuery(query, "jdbc")); | ||
verifySchema(result, schema("phrase", "text")); | ||
|
||
verifyDataRows(result, | ||
rows("my test"), | ||
rows("my test 2")); | ||
} | ||
|
||
@Test | ||
public void no_matches_test() throws IOException { | ||
String query = "SELECT * FROM " | ||
+ TEST_INDEX_PHRASE + " WHERE match_bool_prefix(phrase, 'rice')"; | ||
var result = new JSONObject(executeQuery(query, "jdbc")); | ||
assertEquals(0, result.getInt("total")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -594,4 +594,4 @@ public void fieldWithSpacesInNameShouldPass() { | |
Assert.assertSame(TEXT, type.get()); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.