{"record":{"id":"ce610fd2b1078de6","repo":"apache/druid","slug":"s-cannot-be-used-as-an-output-name-for-dimensio","errorCode":null,"errorMessage":"'%s' cannot be used as an output name for dimensions, aggregators, or post-aggregators.","messagePattern":"'(.+?)' cannot be used as an output name for dimensions, aggregators, or post-aggregators\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java","lineNumber":917,"sourceCode":"      if (!outputNames.add(dimension.getOutputName())) {\n        throw new IAE(\"Duplicate output name[%s]\", dimension.getOutputName());\n      }\n    }\n\n    for (AggregatorFactory aggregator : aggregators) {\n      if (!outputNames.add(aggregator.getName())) {\n        throw new IAE(\"Duplicate output name[%s]\", aggregator.getName());\n      }\n    }\n\n    for (PostAggregator postAggregator : postAggregators) {\n      if (!outputNames.add(postAggregator.getName())) {\n        throw new IAE(\"Duplicate output name[%s]\", postAggregator.getName());\n      }\n    }\n\n    if (outputNames.contains(ColumnHolder.TIME_COLUMN_NAME)) {\n      throw new IAE(\n          \"'%s' cannot be used as an output name for dimensions, aggregators, or post-aggregators.\",\n          ColumnHolder.TIME_COLUMN_NAME\n      );\n    }\n  }\n\n  public static class OrderingAndDimensions\n  {\n    Ordering<ResultRow> rowOrdering;\n    List<DimensionSpec> dimensions;\n\n    public OrderingAndDimensions(Ordering<ResultRow> rowOrdering, List<DimensionSpec> dimensions)\n    {\n      this.rowOrdering = rowOrdering;\n      this.dimensions = dimensions;\n    }\n\n    public Ordering<ResultRow> getRowOrdering()","sourceCodeStart":899,"sourceCodeEnd":935,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/groupby/GroupByQuery.java#L899-L935","documentation":"The reserved column name '__time' cannot be used as an output name for any dimension, aggregator, or post-aggregator in a GroupByQuery; the constructor checks outputNames against ColumnHolder.TIME_COLUMN_NAME and throws IAE.","triggerScenarios":"Building/deserializing a query where any dimension outputName, aggregator name, or post-aggregator name equals '__time' (ColumnHolder.TIME_COLUMN_NAME).","commonSituations":"Trying to group on or alias the timestamp column as '__time'; generated queries naming outputs after the underlying segment column; users not realizing __time is reserved.","solutions":["Rename the output (e.g. to 'timestamp' or 'time') and, if needed, extract the timestamp via an extractionFn or a time-floor expression","Use a granularity/extract dimension on __time only for grouping with a different output alias","Never alias any output to the literal '__time' string"],"exampleFix":"// before\nnew DefaultDimensionSpec(\"__time\", \"__time\")\n// after\nnew DefaultDimensionSpec(\"__time\", \"timestamp\")","handlingStrategy":"validation","validationCode":"if (outputNames.contains(\"__time\")) throw new IllegalArgumentException(\"'__time' is a reserved output name\");","typeGuard":"boolean usesReservedTimeColumn(GroupByQuery.Builder b, Collection<String> names) { return names.contains(ColumnHolder.TIME_COLUMN_NAME); }","tryCatchPattern":"try { build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"__time\")) { /* rename output */ } throw e; }","preventionTips":["Never name any output '__time'; use an alias like 'timestamp'","Maintain a reserved-name constant list and check generated query specs against it"],"tags":["groupby","reserved-name","query-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}