-
Notifications
You must be signed in to change notification settings - Fork 25.5k
ESQL: Speed up CASE for some parameters #112295
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
Changes from all commits
2ab7fc0
394b9d7
3979049
5fd2f66
0e1c8ac
19a8247
f3abaef
a4af922
3117287
deb5845
3c45129
9b1f6c4
b37d645
e6c0863
85c757e
15ea99c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 112295 | ||
summary: "ESQL: Speed up CASE for some parameters" | ||
area: ES|QL | ||
type: enhancement | ||
issues: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,17 @@ public interface ExpressionEvaluator extends Releasable { | |
/** A Factory for creating ExpressionEvaluators. */ | ||
interface Factory { | ||
ExpressionEvaluator get(DriverContext context); | ||
|
||
/** | ||
* {@code true} if it is safe and fast to evaluate this expression eagerly | ||
* in {@link ExpressionEvaluator}s that need to be lazy, like {@code CASE}. | ||
* This defaults to {@code false}, but expressions | ||
* that evaluate quickly and can not produce warnings may override this to | ||
* {@code true} to get a significant speed-up in {@code CASE}-like operations. | ||
*/ | ||
default boolean eagerEvalSafeInLazy() { | ||
return false; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose this is something that we could derive from the Expression - but it felt simpler to put it here. And it's just a boolean at this point - though maybe it should be a cost estimate at some point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case of constants, the unvisited branches can be removed and the case simplified. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works if the expression is constant, but not if the values are constant. We still have to evaluate in that case. And when we do we can do it the fast way with something like this. |
||
} | ||
|
||
/** | ||
|
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.
another alternative is to be extract this as a marking interface that gets implemented by certain factories.
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 that's a lot less readable.