Skip to content

Commit

Permalink
Merge pull request #1241 from Bit-Quill/Failing-CI-Hot-Fix
Browse files Browse the repository at this point in the history
Hot Fix For CI Build
  • Loading branch information
YANG-DB authored Jan 7, 2023
2 parents bac9c37 + a707e3f commit aae57a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import static org.opensearch.sql.expression.function.BuiltinFunctionName.NOT_LIKE;
import static org.opensearch.sql.expression.function.BuiltinFunctionName.POSITION;
import static org.opensearch.sql.expression.function.BuiltinFunctionName.REGEXP;
import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AltMultiFieldRelevanceFunctionContext;
import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AltSingleFieldRelevanceFunctionContext;
import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AlternateMultiMatchFieldContext;
import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AlternateMultiMatchQueryContext;
import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.BetweenPredicateContext;
import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.BinaryComparisonPredicateContext;
import static org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.BooleanContext;
Expand Down Expand Up @@ -96,6 +97,7 @@
import org.opensearch.sql.ast.tree.Sort.SortOption;
import org.opensearch.sql.common.utils.StringUtils;
import org.opensearch.sql.expression.function.BuiltinFunctionName;
import org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AlternateMultiMatchQueryContext;
import org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.AndExpressionContext;
import org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.ColumnNameContext;
import org.opensearch.sql.sql.antlr.parser.OpenSearchSQLParser.IdentContext;
Expand Down Expand Up @@ -431,7 +433,7 @@ public UnresolvedExpression visitSingleFieldRelevanceFunction(

@Override
public UnresolvedExpression visitAltSingleFieldRelevanceFunction(
OpenSearchSQLParser.AltSingleFieldRelevanceFunctionContext ctx) {
AltSingleFieldRelevanceFunctionContext ctx) {
return new Function(
ctx.altSyntaxFunctionName.getText().toLowerCase(),
altSingleFieldRelevanceFunctionArguments(ctx));
Expand Down Expand Up @@ -460,7 +462,7 @@ public UnresolvedExpression visitMultiFieldRelevanceFunction(

@Override
public UnresolvedExpression visitAltMultiFieldRelevanceFunction(
OpenSearchSQLParser.AltMultiFieldRelevanceFunctionContext ctx) {
AltMultiFieldRelevanceFunctionContext ctx) {
return new Function(
ctx.altSyntaxFunctionName.getText().toLowerCase(),
altMultiFieldRelevanceFunctionArguments(ctx));
Expand Down Expand Up @@ -523,12 +525,12 @@ private List<UnresolvedExpression> singleFieldRelevanceArguments(


private List<UnresolvedExpression> altSingleFieldRelevanceFunctionArguments(
OpenSearchSQLParser.AltSingleFieldRelevanceFunctionContext ctx) {
AltSingleFieldRelevanceFunctionContext ctx) {
// all the arguments are defaulted to string values
// to skip environment resolving and function signature resolving
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder();
builder.add(new UnresolvedArgument("field",
new Literal(StringUtils.unquoteText(ctx.field.getText()), DataType.STRING)));
new QualifiedName(StringUtils.unquoteText(ctx.field.getText()))));
builder.add(new UnresolvedArgument("query",
new Literal(StringUtils.unquoteText(ctx.query.getText()), DataType.STRING)));
fillRelevanceArgs(ctx.relevanceArg(), builder);
Expand Down Expand Up @@ -591,7 +593,7 @@ private List<UnresolvedExpression> alternateMultiMatchArguments(
}

private List<UnresolvedExpression> altMultiFieldRelevanceFunctionArguments(
OpenSearchSQLParser.AltMultiFieldRelevanceFunctionContext ctx) {
AltMultiFieldRelevanceFunctionContext ctx) {
// all the arguments are defaulted to string values
// to skip environment resolving and function signature resolving
var map = new HashMap<String, Float>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,53 +576,53 @@ public void relevanceMatch_Query() {
public void relevanceMatchQueryAltSyntax() {
assertEquals(AstDSL.function("match_query",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = match_query('search query')")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = match_query('search query')").toString()
);

assertEquals(AstDSL.function("match_query",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = match_query(\"search query\")")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = match_query(\"search query\")").toString()
);

assertEquals(AstDSL.function("matchquery",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = matchquery('search query')")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = matchquery('search query')").toString()
);

assertEquals(AstDSL.function("matchquery",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = matchquery(\"search query\")")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = matchquery(\"search query\")").toString()
);
}

@Test
public void relevanceMatchPhraseAltSyntax() {
assertEquals(AstDSL.function("match_phrase",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = match_phrase('search query')")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = match_phrase('search query')").toString()
);

assertEquals(AstDSL.function("match_phrase",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = match_phrase(\"search query\")")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = match_phrase(\"search query\")").toString()
);

assertEquals(AstDSL.function("matchphrase",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = matchphrase('search query')")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = matchphrase('search query')").toString()
);

assertEquals(AstDSL.function("matchphrase",
unresolvedArg("field", stringLiteral("message")),
unresolvedArg("query", stringLiteral("search query"))),
buildExprAst("message = matchphrase(\"search query\")")
unresolvedArg("query", stringLiteral("search query"))).toString(),
buildExprAst("message = matchphrase(\"search query\")").toString()
);
}

Expand Down

0 comments on commit aae57a0

Please sign in to comment.