apache/beam · error · ValueError
Unconvertable type
Error message
Unconvertable type: {beam_type} What it means
beam_type_to_avro_type raises this ValueError when the given Beam SchemaJava type matches none of the handled AVRO-mappable categories (primitive, iterable, map, row). It is the fall-through guard of the Beam-to-AVRO schema converter, meaning the type system crossing cannot represent this Beam type in AVRO.
Solutions
- Inspect the offending schema field and replace the unsupported type with an AVRO-mappable one (primitive, array, map with string keys, or row).
- For logical types, either drop the logical wrapper (use the base representation) or extend the conversion yourself before writing.
- Flatten unsupported nested structures into rows/arrays that the converter supports.
- Wrap conversion in try/except ValueError to produce a schema-specific error message identifying the field.
Example fix
// before
row = beam.Row(ts=custom_extension_type)
WriteToAvro('out.avro', schema=beam.schema_from(row))
// after
row = beam.Row(ts=str(custom_extension_type)) # use a supported primitive Defensive patterns
Strategy: try-catch
Validate before calling
def is_avro_mappable(field_type) -> bool:
return field_type.type_info in {
'atomic_type', 'iterable_type', 'map_type', 'row_type'} Try / catch
try:
avro_schema = beam_schema_to_avro_schema(beam_schema)
except ValueError as e:
if str(e).startswith('Unconvertable type'):
logging.error('Unsupported Beam type for AVRO: %s', e)
...
raise Prevention
- Avoid extension/logical types in schemas bound for AVRO sinks
- Pin one apache-beam version across the pipeline
- Test schema-to-AVRO conversion in unit tests for every record type
When it happens
Trigger: Calling beam_schema_to_avro_type()/beam_schema_to_avro_schema() with a Beam FieldType whose type_info is not one of atomic/iterable/map/row — e.g. logical/EXTENSION types or DATETIME variants outside the handled set reaching the converter.
Common situations: Schemas built from custom LogicalType extensions, or schemas produced by newer Beam versions with type kinds the AVRO converter doesn't cover; piping unusual Beam rows into WriteToAvro with schema= provided.
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
- Only strings allowed as map keys when converting to AVRO…
- You are using Avro IO with fastavro (default with Beam on…
- A sink must inherit iobase.Sink, iobase.NativeSink, or be a…
- An explicit schema is required to write non-schema'd…
- apache_beam.io.gcp.datastore.v1new.datastoreio.Entity…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/daa8b70b2f65da69.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/io/avroio.py:748
elif type_info == "map_type":
if beam_type.map_type.key_type.atomic_type != schema_pb2.STRING:
raise TypeError(
f'Only strings allowed as map keys when converting to AVRO, '
f'found {beam_type}')
return {
'type': 'map',
'values': unnest_primitive_type(beam_type.map_type.element_type)
}
elif type_info == "row_type":
return {
'type': 'record',
'name': beam_type.row_type.schema.id,
'fields': [{
'name': field.name, 'type': unnest_primitive_type(field.type)
} for field in beam_type.row_type.schema.fields],
}
else:
raise ValueError(f"Unconvertable type: {beam_type}")
def beam_row_to_avro_dict(
avro_schema: _AvroSchemaType, beam_schema: schema_pb2.Schema):
if isinstance(avro_schema, str):
return beam_row_to_avro_dict({'type': avro_schema}, beam_schema)
if avro_schema['type'] == 'record':
return beam_value_to_avro_value(
schema_pb2.FieldType(row_type=schema_pb2.RowType(schema=beam_schema)))
else:
convert = beam_value_to_avro_value(beam_schema)
return lambda row: convert(row[0])
def beam_value_to_avro_value(
beam_type: schema_pb2.FieldType) -> Callable[[Any], Any]:
type_info = beam_type.WhichOneof("type_info")
if type_info == "atomic_type":View on GitHub (pinned to 12126d8942)