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.
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)
Solutions
- Enable needQueryGranularity on the ExistingSegmentAnalyzer before invoking the getter.
- Provide queryGranularity explicitly in the compaction granularitySpec so inference isn't required.
- 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
- Enable the needQueryGranularity flag when constructing the analyzer.
- Prefer explicit queryGranularity in granularitySpec over inference.
- Keep analyzer flag usage and getter usage in the same code path.
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
- Not computing rollup
- Not computing dimensionsSpec
- Interval[%s] is empty, must specify a nonempty interval
- Conflicting segment granularities found %s(segmentGranularit
- Unknown tuningConfig type: [%s], Must be in [%s, %s, %s]
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/0110200bf10e7227.
Report an issue: GitHub.