apache/druid · error · IllegalArgumentException
A-Not-B requires at least 1 sketch
Error message
A-Not-B requires at least 1 sketch
What it means
The NOT (A-Not-B) set operation of ArrayOfDoublesSketchOperations requires at least one input sketch to compute a difference. The apply() method validates this and throws IllegalArgumentException when sketches.length < 1, since A-Not-B cannot be evaluated with no sketches.
Source
Thrown at extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchOperations.java:71
},
INTERSECT {
@Override
public ArrayOfDoublesSketch apply(final int nominalEntries, final int numberOfValues, final ArrayOfDoublesSketch[] sketches)
{
final ArrayOfDoublesIntersection intersection = new ArrayOfDoublesSetOperationBuilder()
.setNominalEntries(nominalEntries).setNumberOfValues(numberOfValues).buildIntersection();
for (final ArrayOfDoublesSketch sketch : sketches) {
intersection.intersect(sketch, COMBINER);
}
return intersection.getResult();
}
},
NOT {
@Override
public ArrayOfDoublesSketch apply(final int nominalEntries, final int numberOfValues, final ArrayOfDoublesSketch[] sketches)
{
if (sketches.length < 1) {
throw new IAE("A-Not-B requires at least 1 sketch");
}
if (sketches.length == 1) {
return sketches[0];
}
ArrayOfDoublesSketch result = sketches[0];
for (int i = 1; i < sketches.length; i++) {
final ArrayOfDoublesAnotB aNotB = new ArrayOfDoublesSetOperationBuilder().setNumberOfValues(numberOfValues)
.buildAnotB();
aNotB.update(result, sketches[i]);
result = aNotB.getResult();
}
return result;
}
};
public abstract ArrayOfDoublesSketch apply(int nominalEntries, int numberOfValues, ArrayOfDoublesSketch[] sketches);View on GitHub (pinned to 9b90983fd2)
Solutions
- Ensure the post-aggregator fields actually produce sketches for the queried data
- Check query filters/intervals are not excluding all rows feeding the aggregation
- Guard the operation site with a length check before calling apply
Example fix
// before
ArrayOfDoublesSketch result = Operation.NOT.apply(nominalEntries, numValues, sketches);
// after
if (sketches.length == 0) {
return null; // or an empty sketch
}
ArrayOfDoublesSketch result = Operation.NOT.apply(nominalEntries, numValues, sketches); Defensive patterns
Strategy: validation
Validate before calling
if (sketches == null || sketches.length < 1) {
throw new IllegalArgumentException("NOT operation requires at least 1 sketch");
} Type guard
boolean hasSketches = sketches != null && sketches.length >= 1;
Try / catch
try {
result = Operation.NOT.apply(nominalEntries, numValues, sketches);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("requires at least 1 sketch")) {
result = null; // or empty sketch
} else {
throw e;
}
} Prevention
- Validate that post-aggregator fields produce sketches at runtime
- Check query filters do not exclude all input rows
- Prefer deserializeSafe()/null-safe field evaluation upstream
When it happens
Trigger: Invoking ArrayOfDoublesSketchOperations.Operation.NOT.apply() with an empty sketches array, typically from ArrayOfDoublesSketchSetOpPostAggregator when its input fields produce no sketches.
Common situations: A post-aggregator whose field expression filters out all rows and yields no sketches; misconfigured query with an empty or all-null field list that survives the fields>1 constructor check but produces nothing at runtime.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Illegal number of fields[%d], must be > 1
- AggregatorFactoryNotMergeableException(this, other)
- Object is not of a type that can be deserialized to a quanti
- Comparing histograms is not supported
- Cannot accept both 'splitPoints' and 'numBins'
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/5706b23f3d8c1a38.
Report an issue: GitHub.