-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Remove deprecated date histo interval #75000
Conversation
} else { | ||
return new DateHistogramInterval(p.text()); | ||
} | ||
}, Histogram.INTERVAL_FIELD, ObjectParser.ValueType.LONG); |
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.
to support compatibility you can set .forRestApiVersion(equalTo(RestApiVersion.V_7)
on Histogram.INTERVAL_FIELD
this will only parse the field for v7 requests
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.
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
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.
@pgomulka Thanks for your help with this! I think it's all set now for version compatibility now.
Pinging @elastic/es-analytics-geo (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.
ML changes look ✅
So glad to see code being deleted.
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.
LGTM I left one question/suggestion
} else { | ||
wrapper.dateHistogramInterval((DateHistogramInterval) interval); | ||
try { |
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 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?
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.
That link isn't working, but I'm pretty sure I know what you mean. I replaced the try/catch with an if/else.
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.
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 |
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.
Will those tests be part of this PR or you plan to add them in another PR?
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.
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."); |
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.
Nit: Should this be an IllegalArgumentException
instead of a IllegalStateException
.
@elasticmachine update branch |
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.
This will remove the
interval
parameter to date histogram aggregations and composites, deprecated in 7.2. The more precisefixed_interval
andcalendar_interval
options should be used instead.