{"action":"created","comment":{"url":"https://api.github.com/repos/druid-io/druid/pulls/comments/41646342","id":41646342,"diff_hunk":"@@ -158,14 +160,27 @@ public GroupByQueryQueryToolChest(\n       }\n \n       final Sequence<Row> subqueryResult = mergeGroupByResults(subquery, runner, context);\n-      final List<AggregatorFactory> aggs = Lists.newArrayList();\n+      final Set<AggregatorFactory> aggs = Sets.newHashSet();\n+\n       for (AggregatorFactory aggregatorFactory : query.getAggregatorSpecs()) {\n-        aggs.addAll(aggregatorFactory.getRequiredColumns());\n+        for (final AggregatorFactory transferAgg : aggregatorFactory.getRequiredColumns()) {\n+          if (Iterables.any(aggs, new Predicate<AggregatorFactory>() {\n+            @Override\n+            public boolean apply(AggregatorFactory agg) {\n+              return agg.getName().equals(transferAgg.getName()) && !agg.equals(transferAgg);\n+            }\n+          })) {\n+            throw new IAE(\"Inner aggregator can currently only be referenced by a single type of outer aggregator\" +\n+                \" for '%s'\", transferAgg.getName());\n+          }\n+\n+          aggs.add(transferAgg);\n+        }\n       }\n \n       // We need the inner incremental index to have all the columns required by the outer query\n       final GroupByQuery innerQuery = new GroupByQuery.Builder(subquery)\n-          .setAggregatorSpecs(aggs)\n+          .setAggregatorSpecs(Lists.newArrayList(aggs))","path":"processing/src/main/java/io/druid/query/groupby/GroupByQueryQueryToolChest.java","position":37,"original_position":37,"commit_id":"f4e0a76820be2b230d5c672a619c5173a258c11c","original_commit_id":"f4e0a76820be2b230d5c672a619c5173a258c11c","user":{"login":"xvrl","id":815147,"avatar_url":"https://avatars.githubusercontent.com/u/815147?v=3","gravatar_id":"","url":"https://api.github.com/users/xvrl","html_url":"https://github.com/xvrl","followers_url":"https://api.github.com/users/xvrl/followers","following_url":"https://api.github.com/users/xvrl/following{/other_user}","gists_url":"https://api.github.com/users/xvrl/gists{/gist_id}","starred_url":"https://api.github.com/users/xvrl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xvrl/subscriptions","organizations_url":"https://api.github.com/users/xvrl/orgs","repos_url":"https://api.github.com/users/xvrl/repos","events_url":"https://api.github.com/users/xvrl/events{/privacy}","received_events_url":"https://api.github.com/users/xvrl/received_events","type":"User","site_admin":false},"body":"can you add a comment explaining why you need to copy the list?","created_at":"2015-10-09T15:55:53Z","updated_at":"2015-10-09T15:55:53Z","html_url":"https://github.com/druid-io/druid/pull/1799#discussion_r41646342","pull_request_url":"https://api.github.com/repos/druid-io/druid/pulls/1799","_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments/41646342"},"html":{"href":"https://github.com/druid-io/druid/pull/1799#discussion_r41646342"},"pull_request":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1799"}}},"pull_request":{"url":"https://api.github.com/repos/druid-io/druid/pulls/1799","id":46578617,"html_url":"https://github.com/druid-io/druid/pull/1799","diff_url":"https://github.com/druid-io/druid/pull/1799.diff","patch_url":"https://github.com/druid-io/druid/pull/1799.patch","issue_url":"https://api.github.com/repos/druid-io/druid/issues/1799","number":1799,"state":"open","locked":false,"title":"Support multiple outer aggregators of same type and provide more help…","user":{"login":"dclim","id":11050882,"avatar_url":"https://avatars.githubusercontent.com/u/11050882?v=3","gravatar_id":"","url":"https://api.github.com/users/dclim","html_url":"https://github.com/dclim","followers_url":"https://api.github.com/users/dclim/followers","following_url":"https://api.github.com/users/dclim/following{/other_user}","gists_url":"https://api.github.com/users/dclim/gists{/gist_id}","starred_url":"https://api.github.com/users/dclim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dclim/subscriptions","organizations_url":"https://api.github.com/users/dclim/orgs","repos_url":"https://api.github.com/users/dclim/repos","events_url":"https://api.github.com/users/dclim/events{/privacy}","received_events_url":"https://api.github.com/users/dclim/received_events","type":"User","site_admin":false},"body":"…ful exception when the same inner aggregator is referenced by multiple types of outer aggregators\r\n\r\nTemporary bandage for issue with nested group by where an inner aggregator is referenced by more than one outer aggregator. This fix allows multiple references if the outer aggregators are the same (based on 'equals' method), otherwise it throws an exception with a more helpful message than previously. To fully support this would require a larger re-work of the implementation.","created_at":"2015-10-01T21:21:57Z","updated_at":"2015-10-09T15:55:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"87bcfe5d08403948c1b9da939d4264d48f2cf39a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/druid-io/druid/pulls/1799/commits","review_comments_url":"https://api.github.com/repos/druid-io/druid/pulls/1799/comments","review_comment_url":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}","comments_url":"https://api.github.com/repos/druid-io/druid/issues/1799/comments","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/f4e0a76820be2b230d5c672a619c5173a258c11c","head":{"label":"dclim:nested-groupby-aggregator-fix","ref":"nested-groupby-aggregator-fix","sha":"f4e0a76820be2b230d5c672a619c5173a258c11c","user":{"login":"dclim","id":11050882,"avatar_url":"https://avatars.githubusercontent.com/u/11050882?v=3","gravatar_id":"","url":"https://api.github.com/users/dclim","html_url":"https://github.com/dclim","followers_url":"https://api.github.com/users/dclim/followers","following_url":"https://api.github.com/users/dclim/following{/other_user}","gists_url":"https://api.github.com/users/dclim/gists{/gist_id}","starred_url":"https://api.github.com/users/dclim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dclim/subscriptions","organizations_url":"https://api.github.com/users/dclim/orgs","repos_url":"https://api.github.com/users/dclim/repos","events_url":"https://api.github.com/users/dclim/events{/privacy}","received_events_url":"https://api.github.com/users/dclim/received_events","type":"User","site_admin":false},"repo":{"id":42546365,"name":"druid","full_name":"dclim/druid","owner":{"login":"dclim","id":11050882,"avatar_url":"https://avatars.githubusercontent.com/u/11050882?v=3","gravatar_id":"","url":"https://api.github.com/users/dclim","html_url":"https://github.com/dclim","followers_url":"https://api.github.com/users/dclim/followers","following_url":"https://api.github.com/users/dclim/following{/other_user}","gists_url":"https://api.github.com/users/dclim/gists{/gist_id}","starred_url":"https://api.github.com/users/dclim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dclim/subscriptions","organizations_url":"https://api.github.com/users/dclim/orgs","repos_url":"https://api.github.com/users/dclim/repos","events_url":"https://api.github.com/users/dclim/events{/privacy}","received_events_url":"https://api.github.com/users/dclim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dclim/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":true,"url":"https://api.github.com/repos/dclim/druid","forks_url":"https://api.github.com/repos/dclim/druid/forks","keys_url":"https://api.github.com/repos/dclim/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dclim/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dclim/druid/teams","hooks_url":"https://api.github.com/repos/dclim/druid/hooks","issue_events_url":"https://api.github.com/repos/dclim/druid/issues/events{/number}","events_url":"https://api.github.com/repos/dclim/druid/events","assignees_url":"https://api.github.com/repos/dclim/druid/assignees{/user}","branches_url":"https://api.github.com/repos/dclim/druid/branches{/branch}","tags_url":"https://api.github.com/repos/dclim/druid/tags","blobs_url":"https://api.github.com/repos/dclim/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dclim/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dclim/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/dclim/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dclim/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/dclim/druid/languages","stargazers_url":"https://api.github.com/repos/dclim/druid/stargazers","contributors_url":"https://api.github.com/repos/dclim/druid/contributors","subscribers_url":"https://api.github.com/repos/dclim/druid/subscribers","subscription_url":"https://api.github.com/repos/dclim/druid/subscription","commits_url":"https://api.github.com/repos/dclim/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/dclim/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/dclim/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/dclim/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/dclim/druid/contents/{+path}","compare_url":"https://api.github.com/repos/dclim/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dclim/druid/merges","archive_url":"https://api.github.com/repos/dclim/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dclim/druid/downloads","issues_url":"https://api.github.com/repos/dclim/druid/issues{/number}","pulls_url":"https://api.github.com/repos/dclim/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/dclim/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/dclim/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dclim/druid/labels{/name}","releases_url":"https://api.github.com/repos/dclim/druid/releases{/id}","created_at":"2015-09-15T21:02:07Z","updated_at":"2015-09-15T21:02:13Z","pushed_at":"2015-10-01T21:16:57Z","git_url":"git://github.com/dclim/druid.git","ssh_url":"git@github.com:dclim/druid.git","clone_url":"https://github.com/dclim/druid.git","svn_url":"https://github.com/dclim/druid","homepage":"http://druid.io","size":95327,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"druid-io:master","ref":"master","sha":"4da1575680fa4c6f0f231c8d422663b544964f82","user":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"repo":{"id":6358188,"name":"druid","full_name":"druid-io/druid","owner":{"login":"druid-io","id":4203474,"avatar_url":"https://avatars.githubusercontent.com/u/4203474?v=3","gravatar_id":"","url":"https://api.github.com/users/druid-io","html_url":"https://github.com/druid-io","followers_url":"https://api.github.com/users/druid-io/followers","following_url":"https://api.github.com/users/druid-io/following{/other_user}","gists_url":"https://api.github.com/users/druid-io/gists{/gist_id}","starred_url":"https://api.github.com/users/druid-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/druid-io/subscriptions","organizations_url":"https://api.github.com/users/druid-io/orgs","repos_url":"https://api.github.com/users/druid-io/repos","events_url":"https://api.github.com/users/druid-io/events{/privacy}","received_events_url":"https://api.github.com/users/druid-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/druid-io/druid","description":"Column oriented distributed data store ideal for powering interactive applications","fork":false,"url":"https://api.github.com/repos/druid-io/druid","forks_url":"https://api.github.com/repos/druid-io/druid/forks","keys_url":"https://api.github.com/repos/druid-io/druid/keys{/key_id}","collaborators_url":"https://api.github.com/repos/druid-io/druid/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/druid-io/druid/teams","hooks_url":"https://api.github.com/repos/druid-io/druid/hooks","issue_events_url":"https://api.github.com/repos/druid-io/druid/issues/events{/number}","events_url":"https://api.github.com/repos/druid-io/druid/events","assignees_url":"https://api.github.com/repos/druid-io/druid/assignees{/user}","branches_url":"https://api.github.com/repos/druid-io/druid/branches{/branch}","tags_url":"https://api.github.com/repos/druid-io/druid/tags","blobs_url":"https://api.github.com/repos/druid-io/druid/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/druid-io/druid/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/druid-io/druid/git/refs{/sha}","trees_url":"https://api.github.com/repos/druid-io/druid/git/trees{/sha}","statuses_url":"https://api.github.com/repos/druid-io/druid/statuses/{sha}","languages_url":"https://api.github.com/repos/druid-io/druid/languages","stargazers_url":"https://api.github.com/repos/druid-io/druid/stargazers","contributors_url":"https://api.github.com/repos/druid-io/druid/contributors","subscribers_url":"https://api.github.com/repos/druid-io/druid/subscribers","subscription_url":"https://api.github.com/repos/druid-io/druid/subscription","commits_url":"https://api.github.com/repos/druid-io/druid/commits{/sha}","git_commits_url":"https://api.github.com/repos/druid-io/druid/git/commits{/sha}","comments_url":"https://api.github.com/repos/druid-io/druid/comments{/number}","issue_comment_url":"https://api.github.com/repos/druid-io/druid/issues/comments{/number}","contents_url":"https://api.github.com/repos/druid-io/druid/contents/{+path}","compare_url":"https://api.github.com/repos/druid-io/druid/compare/{base}...{head}","merges_url":"https://api.github.com/repos/druid-io/druid/merges","archive_url":"https://api.github.com/repos/druid-io/druid/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/druid-io/druid/downloads","issues_url":"https://api.github.com/repos/druid-io/druid/issues{/number}","pulls_url":"https://api.github.com/repos/druid-io/druid/pulls{/number}","milestones_url":"https://api.github.com/repos/druid-io/druid/milestones{/number}","notifications_url":"https://api.github.com/repos/druid-io/druid/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/druid-io/druid/labels{/name}","releases_url":"https://api.github.com/repos/druid-io/druid/releases{/id}","created_at":"2012-10-23T19:08:07Z","updated_at":"2015-10-08T18:38:09Z","pushed_at":"2015-10-08T18:06:37Z","git_url":"git://github.com/druid-io/druid.git","ssh_url":"git@github.com:druid-io/druid.git","clone_url":"https://github.com/druid-io/druid.git","svn_url":"https://github.com/druid-io/druid","homepage":"http://druid.io","size":177641,"stargazers_count":2056,"watchers_count":2056,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":464,"mirror_url":null,"open_issues_count":181,"forks":464,"open_issues":181,"watchers":2056,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1799"},"html":{"href":"https://github.com/druid-io/druid/pull/1799"},"issue":{"href":"https://api.github.com/repos/druid-io/druid/issues/1799"},"comments":{"href":"https://api.github.com/repos/druid-io/druid/issues/1799/comments"},"review_comments":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1799/comments"},"review_comment":{"href":"https://api.github.com/repos/druid-io/druid/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/druid-io/druid/pulls/1799/commits"},"statuses":{"href":"https://api.github.com/repos/druid-io/druid/statuses/f4e0a76820be2b230d5c672a619c5173a258c11c"}}}}