-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Conversation
Pinging @elastic/ml-core |
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Show resolved
Hide resolved
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/core/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/core/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/core/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
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"}}}, |
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.
Is it worth to add a test for "calendar_interval" as well?
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.
we should add better test coverage for sure, however I think it is ok to do them as follow ups.
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Show resolved
Hide resolved
run elasticsearch-ci/1 |
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.field(NAME); |
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.
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;
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.
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.
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Show resolved
Hide resolved
.../main/java/org/elasticsearch/client/dataframe/transforms/pivot/DateHistogramGroupSource.java
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/core/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/core/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
...n/java/org/elasticsearch/xpack/core/dataframe/transforms/pivot/DateHistogramGroupSource.java
Outdated
Show resolved
Hide resolved
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
private Interval readInterval(StreamInput in) throws IOException { | ||
byte id = in.readByte(); | ||
switch (id) { | ||
case 0: |
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.
[optional]
To avoid magic numbers leaking from the Interval implementations I would:
- Introduce "static final byte INTERVAL_TYPE_ID" fields in both FixedInterval and CalendarInterval classes.
- Return them from "getIntervalTypeId()" method
- Use them here in "switch" clause instead of byte literals
…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
…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
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