apache/druid · error · IllegalStateException

Not computing queryGranularity

Error message

Not computing queryGranularity

What it means

Same contract as getRollup(): ExistingSegmentAnalyzer.getQueryGranularity() throws ISE when queryGranularity analysis was not enabled (needQueryGranularity=false). The value was never computed, so the getter refuses instead of returning a misleading null.

Solutions

  1. Enable needQueryGranularity on the ExistingSegmentAnalyzer before invoking the getter.
  2. Provide queryGranularity explicitly in the compaction granularitySpec so inference isn't required.
  3. Guard the call with a check of the analyzer's need flags (or a prior successful analysis) before reading.

Example fix

// before
ExistingSegmentAnalyzer analyzer = new ExistingSegmentAnalyzer(true, false, true);
Granularity qg = analyzer.getQueryGranularity(); // throws
// after
ExistingSegmentAnalyzer analyzer = new ExistingSegmentAnalyzer(true, true, true);
Granularity qg = analyzer.getQueryGranularity();
Defensive patterns

Strategy: type-guard

Validate before calling

if (analyzer.isComputingQueryGranularity()) { qg = analyzer.getQueryGranularity(); } else { qg = explicitQueryGranularity; }

Type guard

boolean canGetQueryGranularity(ExistingSegmentAnalyzer a) { return a.isComputingQueryGranularity(); }

Try / catch

try { qg = analyzer.getQueryGranularity(); } catch (ISE e) { if (e.getMessage().equals("Not computing queryGranularity")) { qg = explicitValue; } else throw e; }

Prevention

When it happens

Trigger: Calling getQueryGranularity() on an analyzer created without queryGranularity computation enabled; compaction flows that skip metadata analysis but still attempt to read the inferred query granularity.

Common situations: Reused analyzer instances across compaction runs with differing need-flags; code paths adapted from analyzer usages that had queryGranularity enabled.

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/0110200bf10e7227. Report an issue: GitHub.

Appendix: source

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

            processProjections(index);
          }
        }
      }
    }

    public Boolean getRollup()
    {
      if (!needRollup) {
        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 =

View on GitHub (pinned to 9b90983fd2)