apache/druid · error · SamplerException
Failed to sample data: %s
Error message
Failed to sample data: %s
What it means
InputSourceSampler wraps any exception raised while reading and parsing sampled input data into a SamplerException with this message. Sampling runs a short-lived reader over the input source (e.g. for the data loader or ingestion spec preview); failures there — bad input source config, unreadable storage, malformed records — surface through this catch-all. The original exception is attached as the cause and its message is embedded in the entity.
Source
Thrown at indexing-service/src/main/java/org/apache/druid/indexing/overlord/sampler/InputSourceSampler.java:290
);
}
}
return new SamplerResponse(
numRowsRead,
numRowsIndexed,
logicalDimensionSchemas,
physicalDimensionSchemas,
signatureBuilder.build(),
responseRows.stream()
.filter(Objects::nonNull)
.filter(x -> x.getParsed() != null || x.isUnparseable() != null)
.collect(Collectors.toList())
);
}
}
catch (Exception e) {
throw new SamplerException(e, "Failed to sample data: %s", e.getMessage());
}
}
private InputSourceReader buildReader(
SamplerConfig samplerConfig,
DataSchema dataSchema,
InputSource inputSource,
@Nullable InputFormat inputFormat,
File tempDir
)
{
final InputRowSchema inputRowSchema = InputRowSchemas.fromDataSchema(dataSchema);
InputSourceReader reader = inputSource.reader(inputRowSchema, inputFormat, tempDir);
if (samplerConfig.getTimeoutMs() > 0) {
reader = new TimedShutoffInputSourceReader(reader, DateTimes.nowUtc().plusMillis(samplerConfig.getTimeoutMs()));
}View on GitHub (pinned to 9b90983fd2)
Solutions
- Read e.getMessage() / the exception cause in the response — it names the real failure
- Fix the inputSource config (paths, URIs, connection settings, credentials) and retry the sample
- Align the parser/inputFormat with the actual data format before sampling
- Reduce samplerConfig maxRows/targetPartitionSize if huge rows trigger the flush threshold error
Example fix
// before
{"type":"s3","uris":["s3://bucket/wik.json"]} // no credentials configured
// after
{"type":"s3","properties":{"accessKeyId":"...","secretAccessKey":"..."},"uris":["s3://bucket/wik.json"]} Defensive patterns
Strategy: try-catch
Validate before calling
// sanity-check the input source config before sampling
if (!spec.inputSource || !spec.parser && !spec.inputFormat) throw new Error('inputSource and inputFormat required'); Type guard
function isSampleable(spec) { return spec != null && spec.inputSource != null && spec.inputSource.type != null && (spec.inputFormat != null || spec.parser != null); } Try / catch
try { await sample(spec); } catch (e) { if (/Failed to sample data/.test(e.message)) { inspectCause(e); fixInputSourceConfig(); } else throw e; } Prevention
- Validate inputSource paths/credentials before opening the sampler
- Match the parse spec to real data format using a small local file first
- Keep samplerConfig row limits modest during iterative spec development
When it happens
Trigger: POST /druid/indexer/v1/sampler (or via the web-console data loader preview) where opening/reading the InputSource throws: wrong S3/GCS/local path or credentials, unsupported input format, parser/schema mismatch, or the sampler's flush threshold is exceeded.
Common situations: Previewing a Kafka/Kinesis topic with misconfigured bootstrap servers or no read permission; sampling a file whose format does not match the parseSpec; sampling data whose rows fail every parse attempt plus an internal reader bug; timeout reading cold storage.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- No task information found for task with id: [%s]
- Cannot find any supervisor with id: [%s]
- authResult.getErrorMessage()
- Cannot find any task with id: [%s]
- authResult.getErrorMessage()
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/e18e5af589ac3d1b.
Report an issue: GitHub.