Skip to content
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 6 commits into from
Jan 20, 2022

Conversation

joegallo
Copy link
Contributor

@joegallo joegallo commented Jan 19, 2022

Related to #51816 / #68905.

The moving_avg pipeline aggregation was deprecated in #29594 (6.4.0+) and removed via #39328, this PR adds back a nicer error message (but only in the presence of the relevant compatible-with=7 headers).

Quick action shot:

> GET /twitter-1/_search?pretty HTTP/1.1
> Host: localhost:9200
> User-Agent: curl/7.64.1
> Accept: application/vnd.elasticsearch+json;compatible-with=7
> Content-Type: application/vnd.elasticsearch+json;compatible-with=7
> Content-Length: 338
>
* upload completely sent off: 338 out of 338 bytes
< HTTP/1.1 400 Bad Request
< X-elastic-product: Elasticsearch
< Warning: 299 Elasticsearch-8.1.0-SNAPSHOT-bc6bceaca3bbfacfcc92b8a2480db5d38e1c5dec "Deprecated field [moving_avg] used, replaced by [Moving Average aggregation usage is not supported. Use the [moving_fn] aggregation instead.]"
< Warning: 299 Elasticsearch-8.1.0-SNAPSHOT-bc6bceaca3bbfacfcc92b8a2480db5d38e1c5dec "Moving Average aggregation usage is not supported. Use the [moving_fn] aggregation instead."
< content-type: application/json;charset=utf-8
< content-length: 452
<
{
  "error" : {
    "root_cause" : [
      {
        "type" : "parsing_exception",
        "reason" : "Moving Average aggregation usage is not supported. Use the [moving_fn] aggregation instead.",
        "line" : 14,
        "col" : 25
      }
    ],
    "type" : "parsing_exception",
    "reason" : "Moving Average aggregation usage is not supported. Use the [moving_fn] aggregation instead.",
    "line" : 14,
    "col" : 25
  },
  "status" : 400
}
* Connection #0 to host localhost left intact
* Closing connection 0

I expect that the vast majority of direct users of moving_avg have migrated over the last ~3.5 years of it being deprecated, and if you were using it indirectly via Kibana's Moving Avg then you've already been migrated to moving_fn for quite some time (see elastic/kibana#24702).

Side note: funnily enough, because moving_avg and moving_fn are so close together in terms of edit distance, 8.0.0 without the compat header still suggests the latter if you present it with the former. You still get an error, it's the same error you'd get for a typo like movnig_fn.

But only when using compatible-with=7.
foo/bar paths are unusual for these tests, while foo.bar directories
are very usual.
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 19, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Copy link
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good on the REST compat front, @not-napoleon - can you review the agg portion ?

one nit: can you add a comment to the Builder that it can be removed once support for compatibility with v7 is removed.

Copy link
Member

@not-napoleon not-napoleon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an aggregation that's intended to fail at parse time, this looks fine.

@@ -0,0 +1,30 @@
---
Copy link
Member

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.

import java.io.IOException;
import java.util.Map;

public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregationBuilder<MovAvgPipelineAggregationBuilder> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also @deprecate this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍, c1d7a35

@joegallo joegallo merged commit 73ae049 into elastic:master Jan 20, 2022
@joegallo joegallo deleted the moving_avg-rest-api-compat branch January 20, 2022 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.0.0-rc2 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants