Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot Fix For CI Build #1241

Merged
merged 3 commits into from
Jan 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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