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

Fix failure in nested groupBy with multiple aggregators with same fie… #1781

Merged
merged 2 commits into from
Oct 1, 2015
Merged

Fix failure in nested groupBy with multiple aggregators with same fie… #1781

merged 2 commits into from
Oct 1, 2015

Conversation

dclim
Copy link
Contributor

@dclim dclim commented Sep 28, 2015

…ldName

Version 2 - Throws an exception if an outer query references an
aggregator that doesn't exist in the inner query, and then uses the
inner query aggregator names to form the columns for the intermediate
incremental index.

Also deleted all the getRequiredColumns() methods which are no longer
being used.

We do something wacky by adding an aggregator factory for the post
aggregators when building the intermediate incremental index, otherwise
queries on post aggregate results fail because the data isn't in the
incremental index.

Closes #1419

for (final String fieldName : outerAggregator.requiredFields()) {
if (!innerFieldNames.contains(fieldName)) {
throw new IllegalArgumentException(
String.format("Subquery must have an aggregator or post aggregator with name '%s'", fieldName)
Copy link
Contributor

Choose a reason for hiding this comment

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

subquery or outer query?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The subquery needs to have an aggregator with a name that corresponds to the fieldName in the outer query's aggregator function, otherwise when the outer query runs it'll fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

what happens when the outer query needs to access a column that's present in the data and has nothing to do with the sub query?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, the outer query doesn't have visibility into the data, only the results returned from the sub query which have been materialized in the intermediate incremental index.

Copy link
Contributor

Choose a reason for hiding this comment

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

why would it? once the inner query is done, it IS the data

Copy link
Member

Choose a reason for hiding this comment

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

We should make this error message more helpful and explain why the subquery must have the field, e.g. say it is required because it is referenced by the outer query.

@fjy
Copy link
Contributor

fjy commented Sep 29, 2015

👍

…ldName

Version 2 - Throws an exception if an outer query references an
aggregator that doesn't exist in the inner query, and then uses the
inner query aggregator names to form the columns for the intermediate
incremental index.

Also deleted all the getRequiredColumns() methods which are no longer
being used.

We do something wacky by adding an aggregator factory for the post
aggregators when building the intermediate incremental index, otherwise
queries on post aggregate results fail because the data isn't in the
incremental index.

Closes #1419
@dclim dclim closed this Sep 30, 2015
@dclim dclim reopened this Sep 30, 2015
@@ -51,6 +51,7 @@
import io.druid.query.aggregation.JavaScriptAggregatorFactory;
import io.druid.query.aggregation.LongSumAggregatorFactory;
import io.druid.query.aggregation.PostAggregator;
import io.druid.query.aggregation.cardinality.CardinalityAggregatorFactory;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this import is unused?

@gianm
Copy link
Contributor

gianm commented Oct 1, 2015

👍 looks good to me, would appreciate a second set of eyes

fjy added a commit that referenced this pull request Oct 1, 2015
…egator-fix-v2

Fix failure in nested groupBy with multiple aggregators with same fie…
@fjy fjy merged commit dae488b into apache:master Oct 1, 2015
for (AggregatorFactory outerAggregator : query.getAggregatorSpecs()) {
for (final String fieldName : outerAggregator.requiredFields()) {
if (!innerFieldNames.contains(fieldName)) {
throw new IllegalArgumentException(
Copy link
Member

Choose a reason for hiding this comment

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

use IAE instead of String.format

gianm added a commit that referenced this pull request Oct 1, 2015
…ame-aggregator-fix-v2"

This reverts commit dae488b, reversing
changes made to 397be4b.
@gianm
Copy link
Contributor

gianm commented Oct 1, 2015

reverted in e3bb93e

@dclim dclim deleted the nested-groupby-multiple-same-aggregator-fix-v2 branch November 10, 2015 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants