apache/beam · error · UnsupportedOperationException
Unsupported underlying type for producing LogicalType via co
Error message
Unsupported underlying type for producing LogicalType via coder.
What it means
logicalTypeToProto encodes a logical type value via its representation coder into a proto. After encoding, it reads the raw representation back out of the stream; only INT64, DOUBLE, STRING, and BYTES atomic cases are supported. Any other representation type hits this UnsupportedOperationException because the encoded representation cannot be mapped to a proto AtomicTypeValue.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java:765
/** Converts logical type value to a proto using a default type coder. */
private static LogicalTypeValue logicalTypeToProto(
FieldType baseType, FieldType inputType, Object value) {
try {
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(in);
SchemaCoderHelpers.coderForFieldType(inputType).encode(value, out);
out.close(); // Close required for toByteArray.
Object baseObject;
switch (baseType.getTypeName()) {
case INT64:
baseObject = new DataInputStream(in).readLong();
break;
case BYTES:
baseObject = ByteStreams.toByteArray(in);
break;
default:
throw new UnsupportedOperationException(
"Unsupported underlying type for producing LogicalType via coder.");
}
return LogicalTypeValue.newBuilder()
.setValue(fieldValueToProto(baseType, baseObject))
.build();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static LogicalTypeValue logicalTypeToProto(LogicalType logicalType, Object value) {
return LogicalTypeValue.newBuilder()
.setValue(
fieldValueToProto(
logicalType.getBaseType(), SchemaUtils.toLogicalBaseType(logicalType, value)))
.build();
}
View on GitHub (pinned to 12126d8942)
Solutions
- Change the logical type's representation to a primitive (BYTES is the usual safe choice) and serialize complex representations to bytes yourself.
- Upgrade Beam if a newer version supports your representation case in this path.
- Bypass the coder path by ensuring the logical type is registered with a standard URN so logicalTypeToProto(LogicalType, Object) is used instead.
Example fix
// before
public FieldType getRepresentation() { return FieldType.row(mySchema); }
// after
public FieldType getRepresentation() { return FieldType.BYTES; } // serialize struct to bytes in toBaseType Defensive patterns
Strategy: type-guard
Validate before calling
FieldType rep = logicalType.getRepresentation(); if (!coderSafeRepresentation(rep)) throw new IllegalArgumentException("representation " + rep + " unsupported for coder-based logical type encoding"); Type guard
boolean encodableRepresentation(FieldType rep) { switch (rep.getTypeName()) { case INT64: case DOUBLE: case STRING: case BYTES: return true; default: return false; } } Try / catch
try { rowToProto(row); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("Unsupported underlying type for producing LogicalType")) { /* change representation to BYTES */ } else { throw e; } } Prevention
- Declare primitive (ideally BYTES) representations for custom logical types
- Manually serialize structured representations into BYTES
- Round-trip test custom logical types through SchemaTranslation
- Prefer standard logical types with registered URNs
When it happens
Trigger: fieldValueToProto → logicalTypeToProto with a FieldType whose logical type representation is a non-atomic or unsupported FieldType (e.g. ARRAY, ROW, MAP, ITERABLE) routed through the coder-based path.
Common situations: Custom logical type declaring a complex representation type; Beam version where the coder path doesn't support the representation used; schema translated from another system mapping a structured representation onto a Beam logical type.
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
- Unsupported underlying type for parsing logical type via cod
- Unknown DateTime type ${logicalId}
- Azure credential provider type '%s' is not supported
- Unsupported type: <type>
- Unsupported vector type: <type>
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/64a5631670ff033e.
Report an issue: GitHub.