Repository navigation
Relevance Field Validation for single-field Relevance Functions - #186
forestmvey wants to merge 4 commits into
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 |
e32b733 to
f292f81
Compare
…onAnalyzer. Signed-off-by: forestmvey <[email protected]>
f292f81 to
2d25614
Compare
| DSL.match_phrase( | ||
| DSL.namedArgument("field", literal("message")), | ||
| DSL.namedArgument("field", | ||
| new ReferenceExpression("message", OPENSEARCH_TEXT_KEYWORD)), |
There was a problem hiding this comment.
Try different types in all tests, just for fun.
Do you mean with backticks? |
| 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.
this should work for string literals as well as qualifiednames
There was a problem hiding this comment.
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.
| assertEquals( | ||
| AstDSL.function("matchphrasequery", | ||
| unresolvedArg("field", stringLiteral("test")), | ||
| unresolvedArg("field", qualifiedName("test")), |
There was a problem hiding this comment.
this should work for string literals as well as qualifiednames
we should test both, right?
| } | ||
|
|
||
| @Test | ||
| public void missing_field_test() { |
There was a problem hiding this comment.
include test with backticks -> SemanticCheckException
include test with quotes -> no error
backticks are supported as well! |
…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.