-
Notifications
You must be signed in to change notification settings - Fork 25k
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
ESQL: Add interfaces to distribute the post-analysis verification #119798
Conversation
This adds a PostAnalysisAware interface that allows an expression, plan or even command to perform post-analysis verifications "locally", vs. having them centralized in the core verifier.
Hi @bpintea, I've created a changelog YAML for you. |
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 - this looks good. Left some notes clarifying the interface contract however the gist is there.
|
||
public interface PostAnalysisAware { | ||
|
||
default void postAnalysisVerification(Failures failures) {} |
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 we should break interface in two, one that does validation for the current node while another interface performs tree validation.
public interface PostAnalysisVerificationAware
void postAnalysisVerification(Failures failures);
}
and
public interface PostAnalysisPlanVerificationAware
BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification();
}
This way classes can choose which one to pick since so far, it seems only one method is implemented per class and rarely (never?) both.
P.S. In practice the PostAnalysisVerificationAware interface is a subset of the latter:
public interface PostAnalysisVerificationAware extends PostAnalysisPlanVerificationAware
void postAnalysisVerification(Failures failures);
default BiConsumer<LogicalPlan, Failures> postAnalysisPlanVerification() {
return (l,f) -> { if (getClass().isAssignable(f.getClass()) { postAnalysisVerification(f); }
}
}
(though this wrapping should be done in the Verifier to avoid leaking the details to the user).
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 agree. I also thought of this, given the alternative to add default implementations for otherwise an opt-in interface.
|
||
default void postAnalysisVerification(Failures failures) {} | ||
|
||
default BiConsumer<LogicalPlan, Failures> planChecker() { |
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.
for consistency rename this to postAnalysisPlanVerification
|
||
import java.util.function.BiConsumer; | ||
|
||
public interface PostAnalysisAware { |
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.
The interface needs some javadoc with examples.
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.
Added javadoc with examples.
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.esql.analysis; |
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.
Use the org.elasticsearch.xpack.esql.capabilities package instead.
Pinging @elastic/es-analytical-engine (Team:Analytics) |
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 Bogdan - this LGTM!
💔 Backport failed
You can use sqren/backport to manually backport by running |
…astic#119798) This adds a PostAnalysisVerificationAware interface that allows an expression, plan or even command to perform post-analysis verifications "locally", vs. having them centralized in the core verifier. (cherry picked from commit ad264f7)
…Aware (elastic#119985) Rename interface to align it with the similar post-analysis interfaces. Related elastic#119798.
…Aware (elastic#119985) Rename interface to align it with the similar post-analysis interfaces. Related elastic#119798.
This adds two interfaces,
PostAnalysisPlanVerificationAware
andPostAnalysisVerificationAware
, that allow an expression, plan or even command to perform post-analysis verifications "locally", vs. having them centralised in the core verifier.