-
Notifications
You must be signed in to change notification settings - Fork 0
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
Relevance Field Validation for single-field Relevance Functions #186
Relevance Field Validation for single-field Relevance Functions #186
Conversation
Signed-off-by: forestmvey <[email protected]>
…ass OpenSearchFunctions. Signed-off-by: forestmvey <[email protected]>
Codecov Report
@@ Coverage Diff @@
## integ-relevance-fields-validation #186 +/- ##
=======================================================================
- Coverage 98.30% 95.80% -2.51%
+ Complexity 3518 3517 -1
=======================================================================
Files 342 352 +10
Lines 8694 9348 +654
Branches 554 672 +118
=======================================================================
+ Hits 8547 8956 +409
- Misses 142 334 +192
- Partials 5 58 +53
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
integ-test/src/test/java/org/opensearch/sql/sql/QueryStringIT.java
Outdated
Show resolved
Hide resolved
...a/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/SingleFieldQuery.java
Outdated
Show resolved
Hide resolved
...a/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/SingleFieldQuery.java
Outdated
Show resolved
Hide resolved
...g/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/SingleFieldQueryTest.java
Show resolved
Hide resolved
e32b733
to
f292f81
Compare
…onAnalyzer. Signed-off-by: forestmvey <[email protected]>
f292f81
to
2d25614
Compare
@@ -431,7 +435,8 @@ void should_build_match_phrase_query_with_default_parameters() { | |||
+ "}", | |||
buildQuery( | |||
DSL.match_phrase( | |||
DSL.namedArgument("field", literal("message")), | |||
DSL.namedArgument("field", | |||
new ReferenceExpression("message", OPENSEARCH_TEXT_KEYWORD)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try different types in all tests, just for fun.
Do you mean with backticks? |
@@ -475,7 +475,7 @@ private List<UnresolvedExpression> singleFieldRelevanceArguments( | |||
// 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())))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should work for string literals as well as qualifiednames
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for both string literals and qualifiedNames. The relevanceField is treated as a QualifiedName
in the AstExpressionBuilder
and later in the Analyzer
can be visited as a QualifiedName
.
@@ -463,7 +463,7 @@ public void filteredDistinctCount() { | |||
public void matchPhraseQueryAllParameters() { | |||
assertEquals( | |||
AstDSL.function("matchphrasequery", | |||
unresolvedArg("field", stringLiteral("test")), | |||
unresolvedArg("field", qualifiedName("test")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should work for string literals as well as qualifiednames
we should test both, right?
@@ -36,6 +37,18 @@ public void match_in_having() throws IOException { | |||
verifyDataRows(result, rows("Bates")); | |||
} | |||
|
|||
@Test | |||
public void missing_field_test() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include test with backticks -> SemanticCheckException
include test with quotes -> no error
backticks are supported as well! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…ance function field parameters. Signed-off-by: forestmvey <[email protected]>
cfd3144
to
534f52b
Compare
Description
Handle fields validation for single-field relevance functions. Treating field argument as qualified name we can validate as an identifier. This does remove some tests as the type is now interpreted as identifier. Removed tests should be inconsequential as their coverage is done through the V2 parser and now fields identifier validation. Field parameter can be quoted or unquoted and both will be treated as qualified names.
Example Queries
Issues Resolved
Issue: 613
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.