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

[ML-DataFrame] add support for fixed_interval, calendar_interval, remove interval #42427

Merged
merged 14 commits into from
May 24, 2019

Conversation

hendrikmuhs
Copy link

@hendrikmuhs hendrikmuhs commented May 23, 2019

date_histogram interval got deprecated in #33727

data frames should use the new syntax. There is no need to support the old syntax as this feature will be released with 7.2.

fixes #42297

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core

@hendrikmuhs hendrikmuhs requested a review from przemekwitek May 23, 2019 10:59
data_frame.preview_data_frame_transform:
body: >
{
"source": { "index": "airline-data" },
"pivot": {
"group_by": {
"airline": {"terms": {"field": "airline"}},
"by-hour": {"date_histogram": {"interval": "1h", "field": "time", "format": "yyyy-MM-DD HH"}}},
"by-hour": {"date_histogram": {"fixed_interval": "1h", "field": "time", "format": "yyyy-MM-DD HH"}}},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth to add a test for "calendar_interval" as well?

Copy link
Author

Choose a reason for hiding this comment

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

we should add better test coverage for sure, however I think it is ok to do them as follow ups.

@hendrikmuhs hendrikmuhs marked this pull request as ready for review May 23, 2019 14:59
@hendrikmuhs
Copy link
Author

run elasticsearch-ci/1


@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.field(NAME);
Copy link
Contributor

Choose a reason for hiding this comment

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

One more nit: I've just realized it can be compressed to one line using:
return builder.field(NAME, interval);

This call uses the following method, seems this is exactly what is needed here:
public XContentBuilder field(String name, ToXContent value) throws IOException;

Copy link
Contributor

Choose a reason for hiding this comment

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

The way it's done at the moment the params are preserved. It doesn't matter now but in the future it could make a difference.

Copy link
Contributor

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

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

LGTM

private Interval readInterval(StreamInput in) throws IOException {
byte id = in.readByte();
switch (id) {
case 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

[optional]
To avoid magic numbers leaking from the Interval implementations I would:

  1. Introduce "static final byte INTERVAL_TYPE_ID" fields in both FixedInterval and CalendarInterval classes.
  2. Return them from "getIntervalTypeId()" method
  3. Use them here in "switch" clause instead of byte literals

@hendrikmuhs hendrikmuhs merged commit 44c1551 into elastic:master May 24, 2019
hendrikmuhs pushed a commit that referenced this pull request May 24, 2019
…ove interval (#42427)

* add support for fixed_interval, calendar_interval, remove interval

* adapt HLRC

* checkstyle

* add a hlrc to server test

* adapt yml test

* improve naming and doc

* improve interface and add test code for hlrc to server

* address review comments

* repair merge conflict

* fix date patterns

* address review comments

* remove assert for warning

* improve exception message

* use constants
gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this pull request May 27, 2019
…ove interval (elastic#42427)

* add support for fixed_interval, calendar_interval, remove interval

* adapt HLRC

* checkstyle

* add a hlrc to server test

* adapt yml test

* improve naming and doc

* improve interface and add test code for hlrc to server

* address review comments

* repair merge conflict

* fix date patterns

* address review comments

* remove assert for warning

* improve exception message

* use constants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML-DataFrame] use calendar|fixed_interval in favor of interval
5 participants