apache/beam · error · IllegalArgumentException

Unsupported thrift type code

Error message

Unsupported thrift type code: %s

What it means

ThriftSchema.beamType maps Thrift field type codes (from TType / thrift metadata) to Beam Schema FieldTypes. When it encounters a Thrift type code it has no mapping for (hits the default branch of its switch), it throws this IllegalArgumentException. It means the Thrift struct being converted uses a type the Beam Thrift schema translation does not support.

Solutions

  1. Identify the offending field's Thrift type from the message and change the struct to use a supported type (e.g. standard list/set/map/string/i32).
  2. Add or extend a mapping case in ThrriftSchema.beamType for the missing type code and rebuild.
  3. Annotate or exclude unsupported fields from schema conversion (e.g. mark them transient/ignored) if they are not needed in the PCollection schema.

Example fix

// before (struct field unsupported)
optional uuid myId;
// after
optional string myId;
Defensive patterns

Strategy: validation

Validate before calling

for (TFieldIdEnum f : supportedFields) {
  checkSupportedType(structMetaData.fieldMetaData.get(f.getThriftFieldId()).typeMetaData.type);
}

Type guard

boolean isSupportedThriftType(byte typeCode) { return Set.of(TType.STOP,TType.BOOL,TType.BYTE,TType.DOUBLE,TType.I16,TType.I32,TType.I64,TType.STRING,TType.STRUCT,TType.MAP,TType.SET,TType.LIST).contains(typeCode); }

Try / catch

try { Schema schema = ThriftSchema.beamType(clazz); } catch (IllegalArgumentException e) { LOG.error("Thrift type unsupported: {}", e.getMessage()); throw new IllegalStateException("Pre-validation failed", e); }

Prevention

When it happens

Trigger: Calling ThriftSchema.beamType (directly or via type/beamType inference, e.g. when using thriftToRow conversions or Schema inference on a Thrift class) with a field whose Thrift type code has no case in the switch, such as unusual or newer thrift container types.

Common situations: Users serializing Thrift structs containing field types not covered by the mapper (e.g. UUID fields, custom thrift types) into Beam Rows; upgrades of the thrift library introduce type codes Beam does not recognize.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/61b32cf15ca43cf6. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/thrift/src/main/java/org/apache/beam/sdk/io/thrift/ThriftSchema.java:382

        final FieldValueMetaData listElemMetadata = ((ListMetaData) metadata).elemMetaData;
        return FieldType.array(beamType(listElemMetadata));
      case TType.MAP:
        final MapMetaData mapMetadata = ((MapMetaData) metadata);
        return FieldType.map(
            beamType(mapMetadata.keyMetaData), beamType(mapMetadata.valueMetaData));
      case TType.STRUCT:
        final StructMetaData structMetadata = ((StructMetaData) metadata);
        return FieldType.row(schemaFor(structMetadata.structClass));
      case TType.ENUM:
        @SuppressWarnings("unchecked")
        final Class<EnumT> enumClass = (Class<EnumT>) ((EnumMetaData) metadata).enumClass;
        @SuppressWarnings("nullness") // it's either "nullness" or "unsafe", apparently
        final EnumT @NonNull [] enumConstants = enumClass.getEnumConstants();
        final String[] enumValues =
            Stream.of(enumConstants).map(EnumT::name).toArray(String[]::new);
        return FieldType.logicalType(EnumerationType.create(enumValues));
      default:
        throw new IllegalArgumentException("Unsupported thrift type code: " + metadata.type);
    }
  }

  private static class FieldExtractor<FieldT extends TFieldIdEnum, T extends @NonNull Object>
      implements FieldValueGetter<T, Object> {
    private final FieldT field;

    private FieldExtractor(FieldT field) {
      this.field = field;
    }

    @Override
    public @Nullable Object get(T thrift) {
      TBase<?, TFieldIdEnum> t = (TBase<?, TFieldIdEnum>) thrift;
      if (!(thrift instanceof TUnion) || t.isSet(field)) {
        final Object value = t.getFieldValue(field);
        if (value instanceof Enum<?>) {
          return ((Enum<?>) value).ordinal();

View on GitHub (pinned to 12126d8942)