apache/beam · error · RuntimeException
Unexpected type {}
Error message
Unexpected type {} What it means
Inside the bytecode-generation helper for selectIntoArrayHelper, the switch over a FieldAccessDescriptor qualifier's FieldType.Kind encountered a kind it has no code-generation branch for. The default arm throws this RuntimeException because only primitive, LIST, MAP, and ROW-like kinds are handled.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/SelectByteBuddyHelpers.java:531
fieldId,
arrayManager,
methodVisitor,
implementationContext));
case MAP:
return size.aggregate(
processMap(
inputType,
fieldAccessDescriptor,
qualifiers,
qualifierPosition,
fieldId,
arrayManager,
methodVisitor,
implementationContext));
default:
throw new RuntimeException("Unexpected type " + qualifier.getKind());
}
}
private StackManipulation.Size processList(
FieldType inputType,
FieldAccessDescriptor fieldAccessDescriptor,
List<Qualifier> qualifiers,
int qualifierPosition,
int fieldId,
ArrayManager arrayManager,
MethodVisitor methodVisitor,
Context implementationContext) {
StackManipulation.Size size = new StackManipulation.Size(0, 0);
FieldType nestedInputType = checkNotNull(inputType.getCollectionElementType());
Schema nestedSchema = getNestedSchema(nestedInputType, fieldAccessDescriptor);
// We create temp local variables to store all the arrays we create. Each field in
// nestedSchema corresponds to a separate array in the output.View on GitHub (pinned to 12126d8942)
Solutions
- Simplify the field selection so nested containers use kinds the generator supports (e.g. select the row field directly instead of diving into the array).
- Flatten or convert the data so the array element type is a primitive or row.
- Check the Beam version: the set of supported kinds grows over time; upgrade to get more switch cases.
- Report/file a Beam issue with the schema and selection expression to get the missing kind case added.
Example fix
// before
PCollection<Row> out = row.apply(Select.fieldNames("events[0].timestamp")); // DATETIME in array -> Unexpected type
// after
// select the whole array, process timestamps after the select
PCollection<Row> out = row.apply(Select.fieldNames("events")); Defensive patterns
Strategy: validation
Validate before calling
for (Schema.Field f : schema.getFields()) {
Schema.TypeName t = f.getType().getTypeName();
if (t == Schema.TypeName.ARRAY || t == Schema.TypeName.ITERABLE) {
Schema.TypeName el = f.getType().getCollectionElement().getTypeName();
if (!(el.isPrimitiveType() || el == Schema.TypeName.ROW || el == Schema.TypeName.MAP))
throw new IllegalArgumentException("Unsupported nested element kind in selection: " + el);
}
} Type guard
boolean selectSupported(Schema.Field f) {
Schema.FieldType t = f.getType();
switch (t.getTypeName()) {
case ARRAY: case ITERABLE: {
Schema.TypeName el = t.getCollectionElement().getTypeName();
return el.isPrimitiveType() || el == Schema.TypeName.ROW || el == Schema.TypeName.MAP;
}
default: return true;
}
} Try / catch
try {
return row.apply(Select.fieldNames(fieldSpec));
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unexpected type")) {
return row.apply(Select.fieldNames(parentField)); // fallback to coarser select
}
throw e;
} Prevention
- Keep nested container element types primitive or ROW
- Check supported qualifier kinds for your Beam version before deep selects
- Prefer selecting parent fields over deep container dives
When it happens
Trigger: Calling selectIntoArrayHelper (through subSelectSize / processList / processMap when generating array element access) with a field whose qualifier type kind is outside the supported set (e.g. unsupported logical/bytes/iterable kind in a nested array selection).
Common situations: Selecting nested array/map elements whose element type is an unusual FieldType (e.g. logical types, DATETIME nested in arrays) that the bytecode selector generator has no case for.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Not an inferred logical type: ${rawType}
- Method ${creator} is not static
- Unable to generate
- Unexpected type {}
- 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/eca995b81ccf9494.
Report an issue: GitHub.