|
| 1 | +/* |
| 2 | + * Copyright OpenSearch Contributors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package org.opensearch.sql.ppl.antlr; |
| 7 | + |
| 8 | +import static org.junit.Assert.assertNotEquals; |
| 9 | + |
| 10 | +import java.util.List; |
| 11 | +import org.antlr.v4.runtime.tree.ParseTree; |
| 12 | +import org.junit.Test; |
| 13 | +import org.junit.runner.RunWith; |
| 14 | +import org.junit.runners.Parameterized; |
| 15 | + |
| 16 | + |
| 17 | +@RunWith(Parameterized.class) |
| 18 | +public class PPLSyntaxParserMatchBoolPrefixSamplesTests { |
| 19 | + |
| 20 | + |
| 21 | + /** Returns sample queries that the PPLSyntaxParser is expected to parse successfully. |
| 22 | + * @return an Iterable of sample queries. |
| 23 | + */ |
| 24 | + @Parameterized.Parameters(name = "{0}") |
| 25 | + public static Iterable<Object> sampleQueries() { |
| 26 | + return List.of( |
| 27 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world')", |
| 28 | + "source=t a = 1 | where match_bool_prefix(a, 'hello world'," |
| 29 | + + " minimum_should_match = 3)", |
| 30 | + "source=t a = 1 | where match_bool_prefix(a, 'hello world', fuzziness='AUTO')", |
| 31 | + "source=t a = 1 | where match_bool_prefix(a, 'hello world', fuzziness='AUTO:4,6')", |
| 32 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world', prefix_length=0)", |
| 33 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world', max_expansions=1)", |
| 34 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world'," |
| 35 | + + " fuzzy_transpositions=true)", |
| 36 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world'," |
| 37 | + + " fuzzy_rewrite=constant_score)", |
| 38 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world'," |
| 39 | + + " fuzzy_rewrite=constant_score_boolean)", |
| 40 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world'," |
| 41 | + + " fuzzy_rewrite=scoring_boolean)", |
| 42 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world'," |
| 43 | + + " fuzzy_rewrite=top_terms_blended_freqs_1)", |
| 44 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world'," |
| 45 | + + " fuzzy_rewrite=top_terms_boost_1)", |
| 46 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world'," |
| 47 | + + " fuzzy_rewrite=top_terms_1)", |
| 48 | + "source=t a= 1 | where match_bool_prefix(a, 'hello world', boost=1)", |
| 49 | + "source=t a = 1 | where match_bool_prefix(a, 'hello world', analyzer = 'standard'," |
| 50 | + + "prefix_length = '0', boost = 1)"); |
| 51 | + } |
| 52 | + |
| 53 | + private final String query; |
| 54 | + |
| 55 | + public PPLSyntaxParserMatchBoolPrefixSamplesTests(String query) { |
| 56 | + this.query = query; |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void test() { |
| 61 | + ParseTree tree = new PPLSyntaxParser().parse(query); |
| 62 | + assertNotEquals(null, tree); |
| 63 | + } |
| 64 | +} |
0 commit comments