-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
[Rest Api Compatibility] MovAvgPipelineAggregation #82828
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d50883c
Add back a nice-r error message for moving_avg
joegallo 638ca76
And a yamlRestTestV7Compat test
joegallo 5f9eb69
Need to filter out this aggregation in the test, too
joegallo 9f56632
Move this nearby test
joegallo deaccd5
Merge branch 'master' into moving_avg-rest-api-compat
joegallo c1d7a35
Deprecate it, and add an explanation
joegallo 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
30 changes: 30 additions & 0 deletions
30
...rc/yamlRestTestV7Compat/resources/rest-api-spec/test/search.aggregation/10_moving_avg.yml
This file contains 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,30 @@ | ||
--- | ||
setup: | ||
- skip: | ||
version: "9.0.0 - " | ||
reason: "compatible from 8.x to 7.x" | ||
features: | ||
- "headers" | ||
|
||
--- | ||
moving_avg agg throws exception: | ||
- do: | ||
catch: "/Moving Average aggregation usage is not supported. Use the \\[moving_fn\\] aggregation instead./" | ||
search: | ||
rest_total_hits_as_int: true | ||
body: | ||
aggs: | ||
the_histo: | ||
date_histogram: | ||
field: "date" | ||
calendar_interval: "1d" | ||
aggs: | ||
the_avg: | ||
avg: | ||
field: "value_field" | ||
the_movavg: | ||
moving_avg: | ||
buckets_path: "the_avg" | ||
headers: | ||
Content-Type: "application/vnd.elasticsearch+json;compatible-with=7" | ||
Accept: "application/vnd.elasticsearch+json;compatible-with=7" |
File renamed without changes.
This file contains 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
75 changes: 75 additions & 0 deletions
75
...java/org/elasticsearch/search/aggregations/pipeline/MovAvgPipelineAggregationBuilder.java
This file contains 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,75 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.search.aggregations.pipeline; | ||
|
||
import org.elasticsearch.common.ParsingException; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.logging.DeprecationLogger; | ||
import org.elasticsearch.core.RestApiVersion; | ||
import org.elasticsearch.index.query.CommonTermsQueryBuilder; | ||
import org.elasticsearch.xcontent.ContextParser; | ||
import org.elasticsearch.xcontent.ParseField; | ||
import org.elasticsearch.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
/** | ||
* The actual moving_avg aggregation was removed as a breaking change in 8.0. This class exists to provide a friendlier error message | ||
* if somebody attempts to use the moving_avg aggregation via the compatible-with=7 mechanism. | ||
* | ||
* We can remove this class entirely when v7 rest api compatibility is dropped. | ||
* | ||
* @deprecated Only for 7.x rest compat | ||
*/ | ||
@Deprecated | ||
public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregationBuilder<MovAvgPipelineAggregationBuilder> { | ||
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. Should we also 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. 👍, c1d7a35 |
||
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(CommonTermsQueryBuilder.class); | ||
public static final String MOVING_AVG_AGG_DEPRECATION_MSG = "Moving Average aggregation usage is not supported. " | ||
+ "Use the [moving_fn] aggregation instead."; | ||
|
||
public static ParseField NAME_V7 = new ParseField("moving_avg").withAllDeprecated(MOVING_AVG_AGG_DEPRECATION_MSG) | ||
.forRestApiVersion(RestApiVersion.equalTo(RestApiVersion.V_7)); | ||
|
||
public static final ContextParser<String, MovAvgPipelineAggregationBuilder> PARSER = (parser, name) -> { | ||
deprecationLogger.compatibleCritical("moving_avg_aggregation", MOVING_AVG_AGG_DEPRECATION_MSG); | ||
throw new ParsingException(parser.getTokenLocation(), MOVING_AVG_AGG_DEPRECATION_MSG); | ||
}; | ||
|
||
public MovAvgPipelineAggregationBuilder(StreamInput in) throws IOException { | ||
super(in, NAME_V7.getPreferredName()); | ||
throw new UnsupportedOperationException("moving_avg is not meant to be used."); | ||
} | ||
|
||
@Override | ||
protected void doWriteTo(StreamOutput out) throws IOException { | ||
throw new UnsupportedOperationException("moving_avg is not meant to be used."); | ||
} | ||
|
||
@Override | ||
protected PipelineAggregator createInternal(Map<String, Object> metadata) { | ||
throw new UnsupportedOperationException("moving_avg is not meant to be used."); | ||
} | ||
|
||
@Override | ||
protected XContentBuilder internalXContent(XContentBuilder builder, Params params) throws IOException { | ||
throw new UnsupportedOperationException("moving_avg is not meant to be used."); | ||
} | ||
|
||
@Override | ||
protected void validate(ValidationContext context) { | ||
throw new UnsupportedOperationException("moving_avg is not meant to be used."); | ||
} | ||
|
||
@Override | ||
public final String getWriteableName() { | ||
return null; | ||
} | ||
} |
This file contains 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
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.
I have never gotten a good answer for why we put BASIC-style line numbers on yml tests, but given that we do, 10 is already in use for
histogram
.