apache/druid · error · IllegalStateException

Not computing dimensionsSpec

Error message

Not computing dimensionsSpec

What it means

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.

Source

Thrown at indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java:1075

        throw new ISE("Not computing rollup");
      }

      return rollup;
    }

    public Granularity getQueryGranularity()
    {
      if (!needQueryGranularity) {
        throw new ISE("Not computing queryGranularity");
      }

      return queryGranularity;
    }

    public DimensionsSpec getDimensionsSpec()
    {
      if (!needDimensionsSpec) {
        throw new ISE("Not computing dimensionsSpec");
      }

      final BiMap<Integer, String> orderedDims = uniqueDims.inverse();

      // Include __time as a dimension only if required, i.e., if it appears in the sort order after position 0.
      final Integer timePosition = uniqueDims.get(ColumnHolder.TIME_COLUMN_NAME);
      final boolean includeTimeAsDimension = timePosition != null && timePosition > 0;

      final List<DimensionSchema> dimensionSchemas =
          IntStream.range(0, orderedDims.size())
                   .mapToObj(i -> {
                     final String dimName = orderedDims.get(i);
                     if (ColumnHolder.TIME_COLUMN_NAME.equals(dimName) && !includeTimeAsDimension) {
                       return null;
                     } else {
                       return dimensionSchemaMap.get(dimName);
                     }
                   })

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Enable needDimensionsSpec so the analyzer scans segments and collects dimensions before the getter is called.
  2. Supply an explicit dimensionsSpec in the compaction config instead of relying on inference.
  3. Verify that at least one segment in the interval was successfully processed (processSegment/processRollup ran) before reading results.

Example fix

// before
ExistingSegmentAnalyzer analyzer = new ExistingSegmentAnalyzer(true, true, false);
DimensionsSpec dims = analyzer.getDimensionsSpec(); // throws
// after
ExistingSegmentAnalyzer analyzer = new ExistingSegmentAnalyzer(true, true, true);
analyzer.processSegment(...);
DimensionsSpec dims = analyzer.getDimensionsSpec();
Defensive patterns

Strategy: type-guard

Validate before calling

if (analyzer.isComputingDimensionsSpec()) { dims = analyzer.getDimensionsSpec(); } else { dims = explicitDimensionsSpec; }

Type guard

boolean canGetDimensionsSpec(ExistingSegmentAnalyzer a) { return a.isComputingDimensionsSpec(); }

Try / catch

try { dims = analyzer.getDimensionsSpec(); } catch (ISE e) { if (e.getMessage().equals("Not computing dimensionsSpec")) { dims = explicitSpec; } else throw e; }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/1d52f4296db64ad5. Report an issue: GitHub.