apache/iceberg · error · IllegalStateException
Not a set predicate:
Error message
Not a set predicate:
What it means
BoundSetPredicate represents IN/NOT_IN predicates over a set of literals; asSetPredicate() is the narrowing accessor for it. The base BoundPredicate throws IllegalStateException here because most bound predicates (comparisons, unary predicates) are not set predicates. Guard with isSetPredicate() before calling.
Solutions
- Check predicate.isSetPredicate() before calling asSetPredicate()
- Branch on predicate kind before accessing set-specific state
- Ensure the expression was bound with Binder.bind; binding normalizes single-element IN into literal predicates
Example fix
// before
BoundSetPredicate<?> set = boundPred.asSetPredicate();
// after
if (boundPred.isSetPredicate()) {
BoundSetPredicate<?> set = boundPred.asSetPredicate();
} Defensive patterns
Strategy: type-guard
Validate before calling
if (!pred.isSetPredicate()) { throw new IllegalArgumentException("expected set predicate, got " + pred.op()); } Type guard
function asSet(p) { return p.isSetPredicate() ? p.asSetPredicate() : null; } Try / catch
try { set = pred.asSetPredicate(); } catch (IllegalStateException e) { /* handle non-set predicate */ } Prevention
- Check isSetPredicate() before extracting IN-set literals
- Handle literal and unary predicate cases alongside set predicates
- Remember binding collapses single-element IN to a literal predicate
When it happens
Trigger: Calling asSetPredicate() on a BoundPredicate that is actually a BoundLiteralPredicate or BoundUnaryPredicate, e.g. when collecting IN clause literals from a bound expression without checking the predicate kind.
Common situations: Scan-planning or partition-pruning code that extracts IN-set values from filter expressions but encounters a simple == or IS NULL predicate instead.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Not a literal predicate:
- AboveMax has no comparator
- BelowMin has no comparator
- BelowMin has no value
- Cannot change the type of BelowMin
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/e4e1a6c957c650c7.
Report an issue: GitHub.
Appendix: source
Thrown at api/src/main/java/org/apache/iceberg/expressions/BoundPredicate.java:66
public BoundUnaryPredicate<T> asUnaryPredicate() {
throw new IllegalStateException("Not a unary predicate: " + this);
}
public boolean isLiteralPredicate() {
return false;
}
public BoundLiteralPredicate<T> asLiteralPredicate() {
throw new IllegalStateException("Not a literal predicate: " + this);
}
public boolean isSetPredicate() {
return false;
}
public BoundSetPredicate<T> asSetPredicate() {
throw new IllegalStateException("Not a set predicate: " + this);
}
}
View on GitHub (pinned to 86d9c8fc54)