apache/beam · error · java.lang.IllegalArgumentException
Not a primitive type for field name %s: %s
Error message
Not a primitive type for field name %s: %s
What it means
RowUtils' row/iterable matching walker hits a Schema field whose type is not one of the primitive cases it handles (BYTE, INT16, INT32, INT64, FLOAT, DOUBLE, STRING, BOOLEAN, DATETIME, INSTANT, DECIMAL, BYTES). The default branch is a defensive catch-all: the switch should already have dispatched every primitive, so this means the value produced a processed value only via a path that fell through, i.e. the field's SchemaType was not matched anywhere. It signals an internal type-dispatch failure while validating/capturing a Row's field values.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/values/RowUtils.java:208
break;
case DECIMAL:
processedValue = cases.processDecimal(rowPosition, (BigDecimal) value, this);
break;
case FLOAT:
processedValue = cases.processFloat(rowPosition, (Float) value, this);
break;
case DOUBLE:
processedValue = cases.processDouble(rowPosition, (Double) value, this);
break;
case STRING:
processedValue = cases.processString(rowPosition, (String) value, this);
break;
case BOOLEAN:
processedValue = cases.processBoolean(rowPosition, (Boolean) value, this);
break;
default:
// Shouldn't actually get here, but we need this case to satisfy linters.
throw new IllegalArgumentException(
String.format(
"Not a primitive type for field name %s: %s", rowPosition.descriptor, fieldType));
}
if (processedValue == null) {
if (!fieldType.getNullable()) {
throw new IllegalArgumentException(
String.format("%s is not nullable in field %s", fieldType, rowPosition.descriptor));
}
}
return processedValue;
}
}
static class FieldOverride {
FieldOverride(Object overrideValue) {
this.overrideValue = overrideValue;
}
View on GitHub (pinned to 12126d8942)
Solutions
- Check the field's Schema.FieldType; ensure container fields (ARRAY/ITERABLE/MAP) are declared as such so they dispatch to processArray/processMap rather than the primitive switch
- For LOGICAL_TYPE fields, register the logical type and ensure its base type is a primitive the switch supports
- Verify the Beam SDK version supports the type in question; upgrade or replace unsupported field types
- If it seems like an internal bug, file/report to Beam with the schema; the comment says this branch 'shouldn't actually get here'
Example fix
// before (schema field misdeclared)
Schema.Field.of("tags", Schema.FieldType.STRING) // values are actually a list
// after
Schema.Field.of("tags", Schema.FieldType.array(Schema.FieldType.STRING)) Defensive patterns
Strategy: validation
Validate before calling
Schema.FieldType ft = schema.getField(name).getType();
if (!ft.getTypeName().isPrimitiveType() && !ft.getTypeName().equals(Schema.TypeName.LOGICAL_TYPE)) {
throw new IllegalArgumentException("Unhandled field type for " + name + ": " + ft);
} Prevention
- Declare container fields (arrays/maps) with FieldType.array/map so they dispatch correctly
- Ensure logical types are registered and backed by a supported primitive
- Keep Beam SDK versions consistent across the pipeline
When it happens
Trigger: Calling RowUtils.attachSchema or Row.withSchema-style matching (via processRow/capturedElement/processMap) on a Row whose field has a Schema.TypeName not handled by the switch — typically a LOGICAL_TYPE or newly added type, or a nested container type that reached the leaf matcher instead of the array/map branch.
Common situations: Using a custom logical type (e.g. Joda/Java-time wrappers) or a portable logical type in a schema and then serializing/comparing rows; running code written for an older Beam version against a schema containing types the switch did not know; building rows with mismatched Schema objects where a container type is misdeclared as a leaf.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Cannot provide a coder for a Beam Row. Please provide a sche
- Row expected <fieldCount> fields (<fields>). initialized wit
- Null value set on non-nullable field <field>
- Failed to decode Schema due to an error decoding Field proto
- Encountered UNSPECIFIED AtomicType
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/1d80fdb06413f10e.
Report an issue: GitHub.