-
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
Use query execution start time as the value of now-like functions. #1047
Use query execution start time as the value of now-like functions. #1047
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x #1047 +/- ##
============================================
- Coverage 98.29% 95.79% -2.51%
- Complexity 3465 3470 +5
============================================
Files 347 358 +11
Lines 8647 9315 +668
Branches 550 668 +118
============================================
+ Hits 8500 8923 +423
- 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. |
6614306
to
428b216
Compare
core/src/main/java/org/opensearch/sql/expression/function/BuiltinFunctionRepository.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/function/BuiltinFunctionRepository.java
Outdated
Show resolved
Hide resolved
@@ -51,8 +56,14 @@ public BuiltinFunctionRepository functionRepository() { | |||
return builtinFunctionRepository; | |||
} | |||
|
|||
@Bean |
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.
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.
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.
Not exactally.
- ApplicationContext should be created per-node instead of per-request. Which means FunctionProperties should not been created in ApplicationContext.
- @dai-chen also think of making FunctionRepositoy as singleton. Reference, Decouple function repository and DSL from IoC container for use anywhere #1045
I think FunctionProperties should be in a context and pass as paramater to Analyzer and FunctionProperties.
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.
@penghuo, I will move Spring setup to SQLPlugin.createComponents
and update as appropriate.
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.
@penghuo, I will move Spring setup to
SQLPlugin.createComponents
and update as appropriate.
As discussed offline with @penghuo , this PR will wait on merge of #1045 into 2.x
branch.
cc @dai-chen
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 FunctionProperties interface to capture query metadata and provide to function implementations. - Update FunctionBuilder to take FunctionProperties in addition to function arguments when evaluating a SQL function. - Implement now-like functions using FunctionProperties. - Add FunctionDSL.nullMissingHandlingWithProperties to allow for consistent null and missing value handling across all functions. - Remove constant value caching from ExpressionAnalyzer -- the same behavior is now implemented with FunctionProperties. ### Unit Tests - Adjust getQueryStartClock_differs_from_instantNow unit test. On Windows, getQueryStartClock_differs_from_instantNow fails because Instant.now() in the test returns the same value as Instant.now() called for FunctionProperties construction. - Add unit tests for FunctionDSL. - Use Spring to instantiate dsl in OpenSearchTestBase. Signed-off-by: MaxKsyunz <[email protected]>
428b216
to
703275a
Compare
I'm looking into integration test failures. |
Remove FunctionProperties from ExpressionConfig and create it when create<LANG>Service is called. This ensures it's created for each query. Created FunctionPropertiesTestConfig to simplify updating unit tests to work with the change above. Removed an infrequently-used version of BuiltinFunctionRepository.compile and @Getter on BuiltinFunctionRepository.functionProperties -- it was only used for a test -- ExpressionConfigTest. Removed the test because it was testing Spring behavior and not very valuable. Signed-off-by: MaxKsyunz <[email protected]>
e7ccfc2
to
e50074b
Compare
Done. There was a integration test that was instantiating |
The core of reimplementation is to provide FunctionProperties at function compilation in Analyzer *or ExpressionAnalyzer). See FunctionBuilder.apply(FunctionProperties, List<Expression> arguments) AnalysisContext provides an instance of FunctionProperties. The rest of the changes are the consequence of the above. Signed-off-by: MaxKsyunz <[email protected]>
f9270da
# Conflicts: # core/src/main/java/org/opensearch/sql/analysis/Analyzer.java # integ-test/src/test/java/org/opensearch/sql/ppl/StandaloneIT.java # ppl/src/test/java/org/opensearch/sql/ppl/PPLServiceTest.java
Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
They were introduced earlier before BuiltinFunctionRepository became static. Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
Most functions in DSL class do not use FunctionProperties. Use a placeholder instance. Signed-off-by: MaxKsyunz <[email protected]>
Signed-off-by: MaxKsyunz <[email protected]>
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class FunctionPropertiesTestConfig { |
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.
Move TestConfig to 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.
Moved in ea4588e
import java.io.Serializable; | ||
import java.time.Clock; | ||
|
||
public interface FunctionProperties extends Serializable { |
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.
does the interface required? i think NONE could extend FunctionProperties, and QueryFunctionProperties could be removed.
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.
Done in ea4588e
|
||
private final boolean allowExplicitIndex; | ||
|
||
private static final Predicate<String> CONTAINS_SUBQUERY = Pattern.compile("\\(\\s*select ").asPredicate(); |
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 elaborate more the change in RestSqlAction? I did not expect much change should in here.
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.
It's a white space change IntelliJ snuck in during when merging with 2.X.
I'll redo the branch to discard those changes.
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.
Fixed in ea4588e
Signed-off-by: MaxKsyunz <[email protected]>
- Change FunctionProperties into a concrete class. - Move FunctionPropertiesConfig to test since it's only used for testing. Required chaning how PPLServiceTest and StandaloneIT instantiate FunctionProperties bean. Signed-off-by: MaxKsyunz <[email protected]>
…pensearch-project#1047) Signed-off-by: Margarit Hakobyan <[email protected]>
Description
Unit Tests
Signed-off-by: MaxKsyunz [email protected]
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.