-
Notifications
You must be signed in to change notification settings - Fork 139
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
Refactor OpenSearch Relevance Functions out of Core #2019
base: main
Are you sure you want to change the base?
Refactor OpenSearch Relevance Functions out of Core #2019
Conversation
* Created Relevance and OpenSeach Functions in opensearch module Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Moving Test in progress. Committing for rebase purposes Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Moved tests out from core Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Pulled out analyzers to opensearch module Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Revert "Pulled out analyzers to opensearch module" This reverts commit a602e30. * Fixed jacoco for opensearch module Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Refactor out OpenSearchFunction from OpenSearchFunctions; Move OpenSearchFunctions and RelevanceFunctionResolver Signed-off-by: acarbonetto <andrewc@bitquilltech.com> * Fixed tests in core. WIP Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Update to use OpenSearchDSL Signed-off-by: acarbonetto <andrewc@bitquilltech.com> * Fixed nested test coverage Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Update datasource metadata to check for initial cluster state Signed-off-by: acarbonetto <andrewc@bitquilltech.com> * Add score functions to analyzer test Signed-off-by: acarbonetto <andrewc@bitquilltech.com> * Re-add nested tests into core Signed-off-by: acarbonetto <andrewc@bitquilltech.com> * Added hashcode for DataSourceMetadata Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Added test for score without boost Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Re-add nested tests in Analyzer Signed-off-by: acarbonetto <andrewc@bitquilltech.com> * Clean up analyzer tests Signed-off-by: acarbonetto <andrewc@bitquilltech.com> * Cleaned up some code Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> * Fix jacoco and add unit tests for coverage Signed-off-by: acarbonetto <andrewc@bitquilltech.com> --------- Signed-off-by: Guian Gumpac <guian.gumpac@improving.com> Signed-off-by: acarbonetto <andrewc@bitquilltech.com> Co-authored-by: acarbonetto <andrewc@bitquilltech.com>
…vance Signed-off-by: acarbonetto <andrewc@bitquilltech.com>
Signed-off-by: acarbonetto <andrewc@bitquilltech.com>
Codecov Report
@@ Coverage Diff @@
## main #2019 +/- ##
=========================================
Coverage 97.30% 97.30%
- Complexity 4623 4626 +3
=========================================
Files 407 409 +2
Lines 11935 11946 +11
Branches 828 830 +2
=========================================
+ Hits 11613 11624 +11
Misses 315 315
Partials 7 7
Flags with carried forward coverage won't be shown. Click here to find out more.
|
core/src/main/java/org/opensearch/sql/expression/function/BuiltinFunctionRepository.java
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/NestedFunctionResolver.java
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/OpenSearchFunction.java
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/OpenSearchFunction.java
Show resolved
Hide resolved
core/src/test/java/org/opensearch/sql/analysis/OpenSearchAnalyzerTest.java
Show resolved
Hide resolved
core/src/test/java/org/opensearch/sql/expression/function/DefaultFunctionResolverTest.java
Outdated
Show resolved
Hide resolved
assertEquals("match(test=\"test\")", function.toString()); | ||
} | ||
|
||
// @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.
remove
lenient().when(table.createScanBuilder()).thenReturn(tableScanBuilder); | ||
} | ||
|
||
// @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.
remove?
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.
remove this file... it provides no new tests
Signed-off-by: acarbonetto <andrewc@bitquilltech.com>
Signed-off-by: acarbonetto <andrewc@bitquilltech.com>
core/src/test/java/org/opensearch/sql/expression/ExpressionTestBase.java
Show resolved
Hide resolved
opensearch/src/test/java/org/opensearch/sql/opensearch/config/TestConfig.java
Show resolved
Hide resolved
opensearch/src/test/java/org/opensearch/sql/opensearch/expression/ExpressionTestBase.java
Show resolved
Hide resolved
opensearch/src/test/java/org/opensearch/sql/opensearch/planner/DefaultImplementorTest.java
Show resolved
Hide resolved
Signed-off-by: acarbonetto <andrewc@bitquilltech.com>
opensearch/src/test/java/org/opensearch/sql/opensearch/config/TestConfig.java
Show resolved
Hide resolved
opensearch/src/test/java/org/opensearch/sql/opensearch/expression/ExpressionTestBase.java
Show resolved
Hide resolved
import org.opensearch.sql.storage.StorageEngine; | ||
import org.opensearch.sql.storage.Table; | ||
|
||
public class EmptyDataSourceService { |
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.
Need a javadoc and a good description why it is here
@@ -46,7 +49,7 @@ public class BuiltinFunctionRepository { | |||
private final Map<FunctionName, FunctionResolver> functionResolverMap; | |||
|
|||
/** The singleton instance. */ | |||
private static BuiltinFunctionRepository instance; | |||
private static final Map<Integer, BuiltinFunctionRepository> instance = new HashMap<>(); |
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.
Extend the comment and probably rename to instances
.
Set<DataSourceMetadata> dataSourceMetadataSet = dataSourceService.getDataSourceMetadata(true); | ||
Set<Integer> dataSourceServiceHashSet = | ||
dataSourceMetadataSet.stream() | ||
.map(metadata -> metadata.hashCode()) |
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.
I think it could be optimized to
.map(metadata -> metadata.hashCode()) | |
.map(Object::hashCode) |
.getDataSource(metadata.getName()) | ||
.getStorageEngine() | ||
.getFunctions() | ||
.forEach(function -> repository.register(function)); |
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.
.forEach(function -> repository.register(function)); | |
.forEach(repository::register); |
instance.put(metadata.hashCode(), repository); | ||
} |
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.
instance.put(metadata.hashCode(), repository); | |
} | |
} | |
instance.put(metadata.hashCode(), repository); |
new NamedArgumentExpression( | ||
"test", new LiteralExpression(new ExprStringValue("test"))))); | ||
assertEquals(BOOLEAN, function.type()); | ||
assertThrows(UnsupportedOperationException.class, () -> function.valueOf(null)); |
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.
Check exception message
@@ -80,6 +80,9 @@ public OpenSearchDataSourceMetadataStorage( | |||
|
|||
@Override | |||
public List<DataSourceMetadata> getDataSourceMetadata() { | |||
if (!this.clusterService.getClusterApplierService().isInitialClusterStateSet()) { |
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.
Add a comment when this happens
public static final String INT_TYPE_NULL_VALUE_FIELD = "int_null_value"; | ||
public static final String INT_TYPE_MISSING_VALUE_FIELD = "int_missing_value"; | ||
public static final String DOUBLE_TYPE_NULL_VALUE_FIELD = "double_null_value"; | ||
public static final String DOUBLE_TYPE_MISSING_VALUE_FIELD = "double_missing_value"; |
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.
Are all these things used in the test?
public class OpenSearchDSL { | ||
private OpenSearchDSL() {} | ||
|
||
public static LiteralExpression literal(Byte value) { |
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.
No need to copy these things from DSL: literal
, ref
and named
|
||
LogicalPlan plan = | ||
project( | ||
nested( |
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.
No need to copy the entire set. Keep project, nested and values
Description
Moving Relevance-based search functions out of core module and into opensearch module.
This only affects the Function Resolver.
Out of Scope:
Design for refactoring the analyzer and creating an OpenSearch analyzer: Added design for core refactor Bit-Quill/opensearch-project-sql#331
Issues Resolved
Partially fixes #811
Internal review: Bit-Quill#338
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.