-
Notifications
You must be signed in to change notification settings - Fork 141
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
Decouple function repository and DSL from IoC container for use anywhere #1045
Decouple function repository and DSL from IoC container for use anywhere #1045
Conversation
Signed-off-by: Chen Dai <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## feature/maximus-m1 #1045 +/- ##
========================================================
- Coverage 98.27% 95.72% -2.55%
Complexity 3423 3423
========================================================
Files 342 351 +9
Lines 8509 9168 +659
Branches 542 661 +119
========================================================
+ Hits 8362 8776 +414
- Misses 142 334 +192
- Partials 5 58 +53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
Signed-off-by: Chen Dai <[email protected]>
This could be conflicting with #1047. |
Thanks for the heads up. Will review that PR tomorrow. |
Signed-off-by: Chen Dai <[email protected]>
…eton Signed-off-by: Chen Dai <[email protected]>
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.
Thanks for making the change!
@Configuration | ||
@ExtendWith(SpringExtension.class) | ||
@ContextConfiguration(classes = {ExpressionConfig.class}) | ||
@ContextConfiguration(classes = {PhysicalPlanTestBase.class}) |
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.
You can remove these lines now (tested).
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.
Let me give it a try. Thanks!
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.
From my test this is required, otherwise the following error occurred. Not sure if any new changes in 2.x or in your branch locally that I don't have?
Caused by:
java.lang.IllegalStateException: Neither GenericXmlContextLoader nor AnnotationConfigContextLoader was able to load an ApplicationContext from [MergedContextConfiguration@1724c649 testClass = WindowOperatorTest, locations = '{}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextCustomizers = set[[empty]], contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]].
at org.springframework.test.context.support.AbstractDelegatingSmartContextLoader.loadContext(AbstractDelegatingSmartContextLoader.java:256)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
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 just checked out the PR as GH offers:
gh pr checkout 1045
Let me check this again.
@@ -174,5 +178,10 @@ private void validateCatalogs(List<CatalogMetadata> catalogs) { | |||
} | |||
} | |||
|
|||
|
|||
// TODO: for now register storage engine functions here which should be static per storage engine | |||
private void registerFunctions(String catalogName, StorageEngine storageEngine) { |
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.
Can you add this method to the CatalogService
interface?
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.
Could you explain why this need to be an API method of CatalogService
interface? As I understand, storage-engine-defined functions are returned in StorageEngine.getFunctions()
which represents additional capability of a storage engine. CatalogService
can iterate static list of all storage engine (OpenSearch, Prometheus and S3 later) and register all functions internally.
When I compiled code from this PR and run a simple query I got an error in select e();
full
|
Let me test from my side to confirm. Thanks! |
The exception comes from legacy engine. I guess it's not related to this PR and curious about what happened.
|
Right, but I can't reproduce it on |
It's coming from the anonymizer -- it uses v1 ANTLR parser to generate anonymized representation of the query. Unfortunately, the v1 ANTLR parser fails on queries that v1 engine can process.
|
@Yury-Fridlyand @MaxKsyunz Since feature/maximus-m1 is merged back to 2.x, let me rebase this. |
Closing as new PR #1085 based on 2.x branch is published. |
Description
!!!NOTE!!! Please ignore most file changes as they're all changing instance method to static method call on
DSL
. The only change matters is inFunctionRepository
which becomes a singleton after this.Problem Statement
The performance issue is improved in #944, this PR is focused on the functionality and our own DSL language adoption problem.
Currently,
FunctionRepository
is managed by Spring container and inject to class who needs it.DSL
depends on the function repository to resolve function signature as well. This causes the function repository or DSL instance passed around and leads to "ugly" code as below:Besides, the bigger problem is it blocks high level physical operator from building custom logic on top of the expression system. For example, the new
WindowAssigner
needs to calculate the lower bound of a window as below. The current coupling with Spring container make it hard to implement:Solution
After double check, make
FunctionRepository
singleton as well asDSL
. This makes both can be reused anywhere.TODO
Further Thoughts
ExprValue
? ex.val1.add(val2)
rather thanDSL.add(val1, val2).valueOf(null)
<= Not sure. Maybe we should.Issues Resolved
#944
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.