-
Notifications
You must be signed in to change notification settings - Fork 25.3k
SQL: Internal refactoring of operators as functions #34097
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
Conversation
Rename ProcessDefinition to Pipe Add asScript / asPipe onto Expression (might be pushed further down) Add ScriptWeaver as a mixin-in interface for script customization Add logic for equals/lte/lt Improve BinaryOperator/expression toString Minimize duplication across string functions Close elastic#33975
Pinging @elastic/es-search-aggs |
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.
LGTM. Nice stuff! Left two really minor comments.
@@ -59,4 +61,15 @@ public boolean equals(Object obj) { | |||
public int hashCode() { | |||
return location().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.
extra new line :-)
dataType()); | ||
} | ||
|
||
default String formatScript(String template) { |
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.
maybe rename template -> script ?
/** | ||
* Binary operator. Operators act as _special_ functions in that they have a symbol | ||
* instead of a name and do not use parathensis. | ||
* Further more they are don't registered as the rest of the functions as are implicit |
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.
Probably you meant "they are not registered".
import java.util.Objects; | ||
|
||
/** | ||
* Processor definition for math operations requiring two arguments. |
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 a processor definition anymore
import java.util.Objects; | ||
|
||
/** | ||
* Processor definition for String operations requiring one string and one numeric argument. |
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 a processor definition anymore
import java.util.Objects; | ||
|
||
/** | ||
* Processor definition for String operations requiring two string arguments. |
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 a processor definition anymore
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.
Left some minor comments. LGTM
Centralize and simplify the script generation between operators and functions which are currently decoupled. As part of this process most predicates (<, <=, etc...) were made ScalarFunction as their purpose and functionality is quite similar (see % and MOD functions). Renamed ProcessDefinition to Pipe Add ScriptWeaver as a mixin-in interface for script customization Add logic for equals/lte/lt Improve BinaryOperator/expression toString Minimize duplication across string functions Close #33975 (cherry picked from commit 15515a6)
Merged - thanks for the quick reviews! |
* master: Use more precise does S3 bucket exist method (elastic#34123) LLREST: Introduce a strict mode (elastic#33708) [CCR] Adjust list retryable errors (elastic#33985) Fix AggregationFactories.Builder equality and hash regarding order (elastic#34005) MINOR: Remove some deadcode in NodeEnv and Related (elastic#34133) Rest-Api-Spec: Correct spelling in filter_path description (elastic#33154) Core: Don't rely on java time for epoch seconds formatting (elastic#34086) Retry errors when fetching follower global checkpoint. (elastic#34019) Watcher: Reenable watcher stats REST tests (elastic#34107) Remove special-casing of Synonym filters in AnalysisRegistry (elastic#34034) Rename CCR APIs (elastic#34027) Fixed CCR stats api serialization issues and (elastic#33983) Support 'string'-style queries on metadata fields when reasonable. (elastic#34089) Logging: Drop Settings from security logger get calls (elastic#33940) SQL: Internal refactoring of operators as functions (elastic#34097)
Centralize and simplify the script generation between operators and functions which are currently decoupled. As part of this process most predicates (<, <=, etc...) were made ScalarFunction as their purpose and functionality is quite similar (see % and MOD functions). Renamed ProcessDefinition to Pipe Add ScriptWeaver as a mixin-in interface for script customization Add logic for equals/lte/lt Improve BinaryOperator/expression toString Minimize duplication across string functions Close #33975
Sorry for the largish PR, the renaming and moving of some files had a broad effect (the PR actually adds only ~300 loc).
The main goal of this PR is to centralize and simplify the script generation between operators and functions which are currently decoupled. As part of this process most predicates (
<
,<=
, etc...) were madeScalarFunction
as their purpose and functionality is quite similar (see%
andMOD
functions).In a similar vein, the script generation and processing was moved ontowas moved to theExpression
itself as a general concern - it the future it might be tweaked a bit andNamedExpression
.ProcessDefinition
was renamed toPipe
to make the name shorter and a bit more clearer (a Pipe of processes) though it doesn't fully convey its purpose.The advantage of moving this into the expression itself is that OO-ify the generation.
The script customization which was scattered across the code is now centralized into
ScriptWeaver
.In the process, applied de-duplication over some function definitions, in particular String ones.
Lastly, this work started as part of the
NULL
support as every scripted operation, including operators (like-
) need to be made null-safe. This essentially means having the same infrastructure across all pushed-down expressions.Close #33975