sql icon indicating copy to clipboard operation
sql copied to clipboard

Refactor implementation of relevance queries

Open MaxKsyunz opened this issue 3 years ago • 1 comments

Description

  1. Simplified function resolution for relevance query functions.
  2. Throw a SemanticCheckException from RelevanceQuery::build if a parameter is specified more than once. Combined with (1), the end user gets a much better error message.
  3. Introduced MultiFieldQuery and SingleFieldQuery. This allowed for cleaner code in derived classes.
  4. Removed duplicated code from MultiMatchQuery and QueryStringQuery. These functions now throw a SyntaxCheckException if called with insufficient number of parameters. This is in line with other query functions.

Check List

  • [x] New functionality includes testing.
    • [x] All tests pass, including unit test, integration test and doctest
  • [x] Commits are signed per the DCO using --signoff

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.

MaxKsyunz avatar Aug 11 '22 18:08 MaxKsyunz

Codecov Report

Merging #746 (0f13069) into main (29f1c52) will decrease coverage by 0.02%. The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main     #746      +/-   ##
============================================
- Coverage     94.78%   94.76%   -0.03%     
- Complexity     2880     2884       +4     
============================================
  Files           286      289       +3     
  Lines          7735     7699      -36     
  Branches        565      562       -3     
============================================
- Hits           7332     7296      -36     
  Misses          349      349              
  Partials         54       54              
Flag Coverage Δ
query-workbench 62.76% <ø> (ø)
sql-engine 97.75% <100.00%> (-0.02%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...arch/sql/expression/datetime/DateTimeFunction.java 100.00% <ø> (ø)
...search/sql/expression/datetime/IntervalClause.java 100.00% <ø> (ø)
...expression/function/BuiltinFunctionRepository.java 100.00% <ø> (ø)
...ression/operator/arthmetic/ArithmeticFunction.java 100.00% <ø> (ø)
...ssion/operator/arthmetic/MathematicalFunction.java 100.00% <ø> (ø)
.../expression/operator/convert/TypeCastOperator.java 100.00% <ø> (ø)
...on/operator/predicate/BinaryPredicateOperator.java 100.00% <ø> (ø)
...g/opensearch/sql/expression/text/TextFunction.java 100.00% <ø> (ø)
...sql/expression/aggregation/AggregatorFunction.java 100.00% <100.00%> (ø)
...l/expression/function/DefaultFunctionResolver.java 100.00% <100.00%> (ø)
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Aug 11 '22 19:08 codecov-commenter