apache/druid · error · IllegalArgumentException
Specify exactly one of 'interval' and 'segments'
Error message
Specify exactly one of 'interval' and 'segments'
What it means
DruidInputSource's constructor validates that exactly one of the 'interval' and 'segments' properties is supplied when reading from a Druid datasource. Passing both, or neither, makes the segment selection ambiguous, so it throws IllegalArgumentException at construction time.
Source
Thrown at indexing-service/src/main/java/org/apache/druid/indexing/input/DruidInputSource.java:211
}
private DruidInputSource(
final String dataSource,
@Nullable Interval interval,
@Nullable List<WindowedSegmentId> segmentIds,
DimFilter dimFilter,
List<String> dimensions,
List<String> metrics,
IndexIO indexIO,
CoordinatorClient coordinatorClient,
SegmentCacheManagerFactory segmentCacheManagerFactory,
TaskConfig taskConfig,
@Nullable TaskToolbox toolbox
)
{
Preconditions.checkNotNull(dataSource, "dataSource");
if ((interval == null && segmentIds == null) || (interval != null && segmentIds != null)) {
throw new IAE("Specify exactly one of 'interval' and 'segments'");
}
this.dataSource = dataSource;
this.interval = interval;
this.segmentIds = segmentIds;
this.dimFilter = dimFilter;
this.dimensions = dimensions;
this.metrics = metrics;
this.indexIO = Preconditions.checkNotNull(indexIO, "null IndexIO");
this.coordinatorClient = Preconditions.checkNotNull(coordinatorClient, "null CoordinatorClient");
this.segmentCacheManagerFactory = Preconditions.checkNotNull(segmentCacheManagerFactory, "null segmentCacheManagerFactory");
this.taskConfig = Preconditions.checkNotNull(taskConfig, "null taskConfig");
this.toolbox = toolbox;
}
@JsonIgnore
@Nonnull
@Override
public Set<String> getTypes()View on GitHub (pinned to 9b90983fd2)
Solutions
- Remove the 'interval' field from the inputSource spec if you intend to read specific segments via 'segments'.
- Remove the 'segments' field if you intend to read a time range via 'interval'.
- To read everything, keep exactly one field covering the full range (e.g. a wide interval).
Example fix
// before
"inputSource": {"type":"druid","dataSource":"wikipedia","interval":"2020-01-01/2020-02-01","segments":["wikipedia_2020-01-01T00:00:00.000Z_2020-01-02T00:00:00.000Z_2020-01-02T01:00:00.000Z_1"]}
// after
"inputSource": {"type":"druid","dataSource":"wikipedia","segments":["wikipedia_2020-01-01T00:00:00.000Z_2020-01-02T00:00:00.000Z_2020-01-02T01:00:00.000Z_1"]} Defensive patterns
Strategy: validation
Validate before calling
boolean hasInterval = spec.getInterval() != null;
boolean hasSegments = spec.getSegments() != null && !spec.getSegments().isEmpty();
if (hasInterval == hasSegments) {
throw new IllegalArgumentException("Specify exactly one of 'interval' and 'segments'");
} Try / catch
try {
DruidInputSource s = jsonMapper.readValue(specJson, DruidInputSource.class);
} catch (IllegalArgumentException e) {
// fix inputSource spec: keep only 'interval' or only 'segments'
} Prevention
- When targeting specific segments, delete the 'interval' key rather than leaving both.
- Validate inputSource JSON with the Jackson mapper before submitting the task.
- Build specs with mutually exclusive setters that clear the sibling field.
When it happens
Trigger: Constructing DruidInputSource (e.g. from a DruidInputSourceSerDe JSON spec in a reindex/compaction task) with both 'interval' and 'segments' set, or with both null.
Common situations: Copy-pasting a reindex spec and adding 'segments' while forgetting to remove 'interval'; building specs programmatically and leaving both fields null; template reuse carrying over an interval.
Related errors
- Illegal number of fields[%d], must be > 1
- Escape must be null or a single character
- Aggregation [%s] does not support column [%s] of type [%s].
- Cannot accept both 'splitPoints' and 'numBins'
- at least 2 bins expected
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/7e3743e55e9fe653.
Report an issue: GitHub.