{"record":{"id":"1d52f4296db64ad5","repo":"apache/druid","slug":"not-computing-dimensionsspec","errorCode":null,"errorMessage":"Not computing dimensionsSpec","messagePattern":"Not computing dimensionsSpec","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java","lineNumber":1075,"sourceCode":"        throw new ISE(\"Not computing rollup\");\n      }\n\n      return rollup;\n    }\n\n    public Granularity getQueryGranularity()\n    {\n      if (!needQueryGranularity) {\n        throw new ISE(\"Not computing queryGranularity\");\n      }\n\n      return queryGranularity;\n    }\n\n    public DimensionsSpec getDimensionsSpec()\n    {\n      if (!needDimensionsSpec) {\n        throw new ISE(\"Not computing dimensionsSpec\");\n      }\n\n      final BiMap<Integer, String> orderedDims = uniqueDims.inverse();\n\n      // Include __time as a dimension only if required, i.e., if it appears in the sort order after position 0.\n      final Integer timePosition = uniqueDims.get(ColumnHolder.TIME_COLUMN_NAME);\n      final boolean includeTimeAsDimension = timePosition != null && timePosition > 0;\n\n      final List<DimensionSchema> dimensionSchemas =\n          IntStream.range(0, orderedDims.size())\n                   .mapToObj(i -> {\n                     final String dimName = orderedDims.get(i);\n                     if (ColumnHolder.TIME_COLUMN_NAME.equals(dimName) && !includeTimeAsDimension) {\n                       return null;\n                     } else {\n                       return dimensionSchemaMap.get(dimName);\n                     }\n                   })","sourceCodeStart":1057,"sourceCodeEnd":1093,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java#L1057-L1093","documentation":"ExistingSegmentAnalyzer.getDimensionsSpec() throws ISE when dimensions analysis was not requested (needDimensionsSpec=false). The method also builds the dimensions spec from collected unique dimensions, so without analysis there is nothing valid to return.","triggerScenarios":"Calling getDimensionsSpec() on an analyzer not configured to compute dimensions; auto-compaction code reading dimensions after an analysis pass that skipped segment scanning (e.g., no segments could be opened, all metadata missing).","commonSituations":"Compaction over intervals where all segment reads failed or were skipped, leaving analyzer state empty; copied analyzer usage from a context that enabled dimensions analysis.","solutions":["Enable needDimensionsSpec so the analyzer scans segments and collects dimensions before the getter is called.","Supply an explicit dimensionsSpec in the compaction config instead of relying on inference.","Verify that at least one segment in the interval was successfully processed (processSegment/processRollup ran) before reading results."],"exampleFix":"// before\nExistingSegmentAnalyzer analyzer = new ExistingSegmentAnalyzer(true, true, false);\nDimensionsSpec dims = analyzer.getDimensionsSpec(); // throws\n// after\nExistingSegmentAnalyzer analyzer = new ExistingSegmentAnalyzer(true, true, true);\nanalyzer.processSegment(...);\nDimensionsSpec dims = analyzer.getDimensionsSpec();","handlingStrategy":"type-guard","validationCode":"if (analyzer.isComputingDimensionsSpec()) { dims = analyzer.getDimensionsSpec(); } else { dims = explicitDimensionsSpec; }","typeGuard":"boolean canGetDimensionsSpec(ExistingSegmentAnalyzer a) { return a.isComputingDimensionsSpec(); }","tryCatchPattern":"try { dims = analyzer.getDimensionsSpec(); } catch (ISE e) { if (e.getMessage().equals(\"Not computing dimensionsSpec\")) { dims = explicitSpec; } else throw e; }","preventionTips":["Enable the needDimensionsSpec flag when relying on inferred dimensions.","Confirm segments were actually processed before reading dimensionsSpec.","Provide explicit dimensionsSpec for legacy segments lacking metadata."],"tags":["druid","compaction","internal-api","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}