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

Remove deprecated date histo interval #75000

Merged

Conversation

not-napoleon
Copy link
Member

This will remove the interval parameter to date histogram aggregations and composites, deprecated in 7.2. The more precise fixed_interval and calendar_interval options should be used instead.

} else {
return new DateHistogramInterval(p.text());
}
}, Histogram.INTERVAL_FIELD, ObjectParser.ValueType.LONG);
Copy link
Contributor

Choose a reason for hiding this comment

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

to support compatibility you can set .forRestApiVersion(equalTo(RestApiVersion.V_7) on Histogram.INTERVAL_FIELD
this will only parse the field for v7 requests

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, I'm working on that now. It needs to be slightly more clever, because I don't want to keep the field itself in 8.0. Instead we can make a reasonable guess as to how to turn the 7.x version into one of the fields we're replacing it with in 8.0. I'll ping you when I have a draft ready

Copy link
Member Author

Choose a reason for hiding this comment

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

@pgomulka Thanks for your help with this! I think it's all set now for version compatibility now.

@not-napoleon not-napoleon marked this pull request as ready for review July 14, 2021 19:03
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jul 14, 2021
@elasticmachine
Copy link
Collaborator

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

Copy link
Member

@benwtrent benwtrent left a comment

Choose a reason for hiding this comment

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

ML changes look ✅

So glad to see code being deleted. :feelsgood:

Copy link
Contributor

@pgomulka pgomulka left a comment

Choose a reason for hiding this comment

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

LGTM I left one question/suggestion

} else {
wrapper.dateHistogramInterval((DateHistogramInterval) interval);
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we need try catch logic. Maybe we could extract https://github.com/elastic/elasticsearch/pull/75000/files#diff-dd9ebdfdc17eaf7e26fe7cb69a5695245895ff84a1b268b75da2937628f7d8e7R165 check and choose if calendarInterval or fixedInterval should be called?

Copy link
Member Author

Choose a reason for hiding this comment

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

That link isn't working, but I'm pretty sure I know what you mean. I replaced the try/catch with an if/else.

Copy link
Contributor

@csoulios csoulios left a comment

Choose a reason for hiding this comment

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

LGTM! I left some minor comments.

Thanks for cleaning up all this Mark!

assertThat(e.toString(), containsString("[interval] must be 1 or greater for aggregation [date_histogram]"));
}
}
// TODO: add some tests for negative fixed and calendar intervals
Copy link
Contributor

Choose a reason for hiding this comment

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

Will those tests be part of this PR or you plan to add them in another PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was going to add them in later. I don't think it's terribly urgent, and the test I removed only checked it on the legacy interval, so our coverage isn't worse for not adding them now. And it's much less likely to be a problem because fixed & calendar intervals don't just accept bare longs, so a negative will almost definitely fail to parse. Truthfully, I'm not even 100% sure it's worth doing, but I figured a small note was low friction.

default:
throw new IllegalStateException("Unknown interval type.");
if (type.isValid() == false || intervalType.isValid() == false) {
throw new IllegalStateException("Unknown interval type.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Should this be an IllegalArgumentException instead of a IllegalStateException.

@not-napoleon
Copy link
Member Author

@elasticmachine update branch

@not-napoleon not-napoleon merged commit 7af39db into elastic:master Jul 20, 2021
@not-napoleon not-napoleon deleted the remove-deprecated-date-histo-interval branch July 20, 2021 17:55
ywangd pushed a commit to ywangd/elasticsearch that referenced this pull request Jul 30, 2021
Date histogram interval parameter was deprecated in 7.2, in favor of the more specific fixed_interval and calendar_interval parameters.  The old logic used some poorly understood guessing to decide if it should operate in fixed or calendar mode.  The new logic requires a specific choice by the user, which is more explicit.  In 7.x REST compatibility mode, we will parse the interval as calendar if possible, and otherwise interpret it as fixed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >breaking Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants