-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
First and Last Aggregator #3566
Conversation
e5182d5
to
8699fa5
Compare
Still 👍 from me after we resolve merge conflicts |
8699fa5
to
3c069a9
Compare
rebased |
@nishantmonu51 can u review? |
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.
left few comments
@@ -76,6 +76,58 @@ Computes the sum of values as 64-bit floating point value. Similar to `longSum` | |||
{ "type" : "longMax", "name" : <output_name>, "fieldName" : <metric_name> } | |||
``` | |||
|
|||
### First / Last aggregator | |||
|
|||
First and Last aggregator cannot be used in ingestion spec, and should only be specified as part of queries. |
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.
can we also document that if the rows are rolled up, the first/last value will be a the first/last value in druid row and not the raw data being ingested.
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.
Added note about rollup behavior
@@ -171,7 +171,7 @@ public AggregatorFactory getMergingFactory(AggregatorFactory other) throws Aggre | |||
@Override | |||
public AggregatorFactory apply(String input) | |||
{ | |||
return new JavaScriptAggregatorFactory(input, fieldNames, fnAggregate, fnReset, fnCombine, config); | |||
return new JavaScriptAggregatorFactory(input, Lists.newArrayList(input), fnCombine, fnReset, fnCombine, config); |
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.
seems unrelated to this 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.
it's needed due to the changes within groupby in the PR
private final LongColumnSelector timeSelector; | ||
private final String name; | ||
|
||
long firstTime; |
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.
make private ?
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.
made this and others protected, it's accessed by the corresponding AggregatorFactory in getCombiningFactory() when overriding factorize()
private final String name; | ||
|
||
long firstTime; | ||
double firstValue; |
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.
private?
private final String name; | ||
|
||
long firstTime; | ||
long firstValue; |
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.
private ?
private final String name; | ||
|
||
long lastTime; | ||
double lastValue; |
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.
private ?
{ | ||
return new DoubleLastAggregator( | ||
name, metricFactory.makeFloatColumnSelector(fieldName), | ||
metricFactory.makeLongColumnSelector(Column.TIME_COLUMN_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.
minor nit: can we pass time column selector before field selector to be consistent with buffered aggregator ?
@Override | ||
public String toString() | ||
{ | ||
return "DoubleFirstAggregatorFactory{" + |
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.
DoubleLast ?
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.
fixed this name
private final String name; | ||
|
||
long lastTime; | ||
long lastValue; |
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.
private.
{ | ||
return new LongLastAggregator( | ||
name, metricFactory.makeLongColumnSelector(fieldName), | ||
metricFactory.makeLongColumnSelector(Column.TIME_COLUMN_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.
minor nit: can we pass time column selector before field selector to be consistent with buffered aggregator ?
Also, would be nice to add these aggregators to existing integration tests, we can add them to ITTwitterQueryTest and ITWikipediaQueryTest |
1e2f53a
to
2680177
Compare
2680177
to
cc25586
Compare
@nishantmonu51 Addressed your comments aside from the one about integration tests, haven't gotten around to that yet |
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.
👍 from my side, this can be merged after creating an issue to track integration-test changes, if you want to do that in a separate PR.
f362d19
to
11e50b6
Compare
I added some first/last aggs to ITWikipediaQueryTest I didn't add them to ITTwitterQueryTest since I saw the queries there weren't testing the full set of aggs, only using doubleSums generally. I noticed that some other agg types weren't represented in the integration tests (like the max/min or javascript), and it'd be convenient to have a reference to the raw data for |
👍 after travis |
* add first and last aggregator * add test and fix * moving around * separate aggregator valueType * address PR comment * add finalize inner query and adjust v1 inner indexing * better test and fixes * java-util import fixes * PR comments * Add first/last aggs to ITWikipediaQueryTest
… volcano planner
Reopening #3226 from @acslk to finish review/merge