-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[ESQL] Consolidate EsqlProject into Project #140238
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a50528f
[ESQL] Consolidate EsqlProject into Project
MattAlp d87aaf4
[ESQL] Update tests for EsqlProject to Project consolidation
MattAlp 199dd85
Apply spotless & regenerate files
MattAlp d98abac
Update x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/…
MattAlp 7d3cdaf
Update x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/…
MattAlp d819361
Complimentary import for Ievgen's patch
MattAlp f44e553
Handle for-review annotations in ESQL
MattAlp 840258b
Add backwards-compatible deser for project
MattAlp deec3e3
Merge branch 'main' into consolidate-esql-project
MattAlp 31908da
Use canonical name for version-marker annotation processor
MattAlp 455ed68
Merge branch 'main' into consolidate-esql-project
MattAlp 647cfe8
Catch straggling renames
MattAlp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
docs/reference/query-languages/esql/kibana/definition/inline_cast.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...ql/compute/gen/src/main/java/org/elasticsearch/compute/gen/MarkerAnnotationProcessor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.compute.gen; | ||
|
|
||
| import org.elasticsearch.core.UpdateForV10; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| import javax.annotation.processing.Completion; | ||
| import javax.annotation.processing.ProcessingEnvironment; | ||
| import javax.annotation.processing.Processor; | ||
| import javax.annotation.processing.RoundEnvironment; | ||
| import javax.lang.model.SourceVersion; | ||
| import javax.lang.model.element.AnnotationMirror; | ||
| import javax.lang.model.element.Element; | ||
| import javax.lang.model.element.ExecutableElement; | ||
| import javax.lang.model.element.TypeElement; | ||
|
|
||
| /** | ||
| * A no-op annotation processor that claims marker annotations like {@code @UpdateForV10}. | ||
| * <p> | ||
| * These annotations are documentation-only markers (with {@code @Retention(SOURCE)}) used to | ||
| * track code that needs cleanup in future versions. Since the ESQL module uses annotation | ||
| * processors for code generation, the compiler warns about unclaimed annotations. This | ||
MattAlp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * processor claims them to suppress those warnings. | ||
| */ | ||
| public class MarkerAnnotationProcessor implements Processor { | ||
|
|
||
| @Override | ||
| public Set<String> getSupportedOptions() { | ||
| return Set.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<String> getSupportedAnnotationTypes() { | ||
| // Marker annotations that are documentation-only and don't require processing. | ||
| return Set.of(UpdateForV10.class.getCanonicalName()); | ||
| } | ||
|
|
||
| @Override | ||
| public SourceVersion getSupportedSourceVersion() { | ||
| return SourceVersion.RELEASE_21; | ||
| } | ||
|
|
||
| @Override | ||
| public void init(ProcessingEnvironment processingEnvironment) {} | ||
|
|
||
| @Override | ||
| public Iterable<? extends Completion> getCompletions( | ||
| Element element, | ||
| AnnotationMirror annotationMirror, | ||
| ExecutableElement executableElement, | ||
| String s | ||
| ) { | ||
| return Set.of(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment) { | ||
| return true; | ||
| } | ||
| } | ||
1 change: 1 addition & 0 deletions
1
...ql/compute/gen/src/main/resources/META-INF/services/javax.annotation.processing.Processor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| org.elasticsearch.compute.gen.AggregatorProcessor | ||
| org.elasticsearch.compute.gen.ConsumeProcessor | ||
| org.elasticsearch.compute.gen.EvaluatorProcessor | ||
| org.elasticsearch.compute.gen.MarkerAnnotationProcessor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
| import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.xpack.esql.core.capabilities.Resolvables; | ||
| import org.elasticsearch.core.UpdateForV10; | ||
| import org.elasticsearch.xpack.esql.core.expression.Alias; | ||
| import org.elasticsearch.xpack.esql.core.expression.Attribute; | ||
| import org.elasticsearch.xpack.esql.core.expression.Expressions; | ||
|
|
@@ -18,6 +18,7 @@ | |
| import org.elasticsearch.xpack.esql.core.tree.NodeInfo; | ||
| import org.elasticsearch.xpack.esql.core.tree.Source; | ||
| import org.elasticsearch.xpack.esql.expression.function.Functions; | ||
| import org.elasticsearch.xpack.esql.expression.function.UnsupportedAttribute; | ||
| import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput; | ||
|
|
||
| import java.io.IOException; | ||
|
|
@@ -30,11 +31,42 @@ | |
| public class Project extends UnaryPlan implements Streaming, SortAgnostic, SortPreserving { | ||
| public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(LogicalPlan.class, "Project", Project::new); | ||
|
|
||
| /** | ||
| * Backward compatibility entry + name for reading the consolidated `EsqlProject` plans from pre-9.4.0 nodes. | ||
| */ | ||
| private static final String LEGACY_PROJECT_NAME = "EsqlProject"; | ||
|
Contributor
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. Nit: If this is something that is targeted to ESQL team, I think |
||
|
|
||
| @UpdateForV10(owner = UpdateForV10.Owner.SEARCH_ANALYTICS) | ||
| public static final NamedWriteableRegistry.Entry V9_ENTRY = new NamedWriteableRegistry.Entry( | ||
| LogicalPlan.class, | ||
| LEGACY_PROJECT_NAME, | ||
MattAlp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Project::readLegacyEsqlProject | ||
| ); | ||
|
|
||
| private static Project readLegacyEsqlProject(StreamInput in) throws IOException { | ||
| return new Project( | ||
| Source.readFrom((PlanStreamInput) in), | ||
| in.readNamedWriteable(LogicalPlan.class), | ||
| in.readNamedWriteableCollectionAsList(NamedExpression.class), | ||
| V9_ENTRY.name | ||
| ); | ||
| } | ||
|
|
||
| private final List<? extends NamedExpression> projections; | ||
| private final String writeableName; | ||
|
|
||
| public Project(Source source, LogicalPlan child, List<? extends NamedExpression> projections) { | ||
| this(source, child, projections, ENTRY.name); | ||
| } | ||
|
|
||
| /** | ||
| * Constructor that allows specifying a custom writeable name for backward compatibility. | ||
| * Used when deserializing legacy "EsqlProject" plans from older cluster versions. | ||
| */ | ||
| private Project(Source source, LogicalPlan child, List<? extends NamedExpression> projections, String writeableName) { | ||
| super(source, child); | ||
| this.projections = projections; | ||
| this.writeableName = writeableName; | ||
| assert validateProjections(projections); | ||
| } | ||
|
|
||
|
|
@@ -55,7 +87,8 @@ private Project(StreamInput in) throws IOException { | |
| this( | ||
| Source.readFrom((PlanStreamInput) in), | ||
| in.readNamedWriteable(LogicalPlan.class), | ||
| in.readNamedWriteableCollectionAsList(NamedExpression.class) | ||
| in.readNamedWriteableCollectionAsList(NamedExpression.class), | ||
| ENTRY.name | ||
| ); | ||
| } | ||
|
|
||
|
|
@@ -68,7 +101,7 @@ public void writeTo(StreamOutput out) throws IOException { | |
|
|
||
| @Override | ||
| public String getWriteableName() { | ||
| return ENTRY.name; | ||
| return writeableName; | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -96,7 +129,13 @@ public boolean resolved() { | |
|
|
||
| @Override | ||
| public boolean expressionsResolved() { | ||
| return Resolvables.resolved(projections); | ||
| for (NamedExpression projection : projections) { | ||
| // don't call dataType() - it will fail on UnresolvedAttribute | ||
| if (projection.resolved() == false && projection instanceof UnsupportedAttribute == false) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should this be moved with the annotation in :libs:core?
Depending on if we can use
UpdateForV10.class.getCanonicalName(), this processor may be difficult to find. Unless it fails on compile time anyway, which could work I guess.