apache/beam · error · IllegalArgumentException
Type not supported ${input}
Error message
Type not supported ${input} What it means
ApproximateCountDistinct.builderForType selects the matching HllCount.Init.Builder for the input TypeDescriptor. If the descriptor matches none of Integer, Long, String, or byte[], builder stays null and IllegalArgumentException "Type not supported" is thrown. This is the type-dispatch guard used by the T-typed construction path.
Source
Thrown at sdks/java/extensions/zetasketch/src/main/java/org/apache/beam/sdk/extensions/zetasketch/ApproximateCountDistinct.java:278
@SuppressWarnings("rawtypes")
HllCount.Init.Builder builder = null;
if (input.equals(TypeDescriptors.strings())) {
builder = HllCount.Init.forStrings();
}
if (input.equals(TypeDescriptors.longs())) {
builder = HllCount.Init.forLongs();
}
if (input.equals(TypeDescriptors.integers())) {
builder = HllCount.Init.forIntegers();
}
if (input.equals(new TypeDescriptor<byte[]>() {})) {
builder = HllCount.Init.forBytes();
}
if (builder == null) {
throw new IllegalArgumentException(String.format("Type not supported %s", input));
}
// Safe to ignore warning, as we know the type based on the check we do above.
@SuppressWarnings("unchecked")
HllCount.Init.Builder<T> output = (HllCount.Init.Builder<T>) builder;
return output;
}
}
View on GitHub (pinned to 12126d8942)
Solutions
- Use one of the explicitly supported types: Integer, Long, String, or byte[].
- Map your input to a supported type with MapElements.via before counting.
- Add an explicit mapping overload call instead of relying on generic type dispatch.
- Inspect the message's type string to confirm which descriptor failed the match.
Example fix
// before
ApproximateCountDistinct.of(new TypeDescriptor<Double>() {});
// after
pc.apply(MapElements.into(TypeDescriptors.longs()).via(d -> (long) Double.doubleToLongBits(d)))
.apply(ApproximateCountDistinct.globally()); Defensive patterns
Strategy: type-guard
Validate before calling
if (!Arrays.asList(Integer.class, Long.class, String.class, byte[].class).contains(type.getRawType())) {
throw new IllegalArgumentException("ApproximateCountDistinct unsupported type: " + type);
} Type guard
boolean isCountDistinctSupported(TypeDescriptor<?> t) {
Class<?> c = t.getRawType();
return c == Integer.class || c == Long.class || c == String.class || c == byte[].class;
} Try / catch
try {
return ApproximateCountDistinct.of(type);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("Type not supported")) { /* map to supported type */ }
throw e;
} Prevention
- Restrict generic T to supported types with bounded type parameters
- Pre-map exotic types with MapElements.via at pipeline edges
- Unit-test type dispatch for each ApproximateCountDistinct overload
When it happens
Trigger: Constructing ApproximateCountDistinct with a generic type T (e.g. via of()/globally for Double, Boolean, or a custom class) whose TypeDescriptor has no registered HllCount initializer.
Common situations: Using ApproximateCountDistinct.of(new TypeDescriptor<Double>(){}) expecting Double support; generic helper methods parameterized over T hitting the unsupported branch at runtime.
Related errors
- ${this.getClass().getCanonicalName()} supports Integer, Long
- ${this.getClass().getCanonicalName()} supports Integer, Long
- input should be array, map, numeric or row
- ${fieldType}
- Field type%s %s not supported when converting between JSON a
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/980e2e2c8829e2e4.
Report an issue: GitHub.