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

Nested groupBy query fails when outer query has multiple aggregators having same "fieldName" #1419

Closed
himanshug opened this issue Jun 3, 2015 · 1 comment

Comments

@himanshug
Copy link
Contributor

Group thread:
https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/druid-user/L4A1iMhzOco/w_5C030krzEJ

Failing Query:

{
  "queryType": "groupBy",
  "dataSource":{
    "type": "query",
    "query": {
      "queryType": "groupBy",
      "dataSource": "platform",
      "granularity": "all",
      "dimensions": ["treatment_name", "subject_id", "dim_app_family"],
      "aggregations": [
        { "type": "longSum", "name": "value", "fieldName": "count" }
      ],
      "intervals": [ "2012-01-01T00:00:00.000/2020-01-03T00:00:00.000" ]
    }
  },
  "granularity": "all",
  "dimensions": ["treatment_name", "dim_app_family"],
  "aggregations": [
    { "type": "longSum", "name": "first_moment", "fieldName": "value" },
    { "type": "javascript",
      "name": "second_moment",
      "fieldNames": ["value"],
      "fnAggregate": "function(current, v) { return current + v * v; } ",
      "fnCombine": "function(partialA, partialB) { return partialA + partialB; }",
      "fnReset": "function() { return 0; }"
    }
  ],
  "intervals": [ "2012-01-01T00:00:00.000/2020-01-03T00:00:00.000" ]
}

Exception Stacktrace:

java.lang.IllegalArgumentException: [value] already defined
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:120)
    at io.druid.query.Queries.verifyAggregations(Queries.java:42)
    at io.druid.query.groupby.GroupByQuery.<init>(GroupByQuery.java:103)
    at io.druid.query.groupby.GroupByQuery$Builder.build(GroupByQuery.java:531)
    at io.druid.query.groupby.GroupByQueryQueryToolChest.mergeGroupByResults(GroupByQueryQueryToolChest.java:160)
@himanshug
Copy link
Contributor Author

The problem happens because we end up building a transient groupBy query that adds all
agg.getRequiredColumns() from original outer query which would have same name.
See https://github.com/druid-io/druid/blob/master/processing/src/main/java/io/druid/query/groupby/GroupByQueryQueryToolChest.java#L163

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

No branches or pull requests

3 participants