apache/flink · error · UnsupportedOperationException

Unsupported type: {}

Error message

Unsupported type: {}

What it means

The default branch of AvroToVariantDataConverters.createConverter: the Avro Schema.Type has no Variant converter. The switch covers primitives, records, arrays, maps, and unions; anything else (e.g. FIXED, or enum depending on coverage) throws UnsupportedOperationException with the schema type name.

Source

Thrown at flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroToVariantDataConverters.java:161

                return createMapConverter(valueConverter);

            case UNION:
                // Handle nullable types (union with null)
                List<Schema> nonNullUnionType =
                        schema.getTypes().stream()
                                .filter(t -> t.getType() != Schema.Type.NULL)
                                .collect(Collectors.toList());

                if (nonNullUnionType.size() == 1) {
                    return createNullableConverter(nonNullUnionType.get(0));
                } else {
                    throw new UnsupportedOperationException(
                            "Avro Union with NULL type is only supported. Unsupported types: "
                                    + schema.getTypes());
                }

            default:
                throw new UnsupportedOperationException("Unsupported type: " + schema.getType());
        }
    }

    /** Creates an array converter that works directly with Avro elements. */
    private static AvroToVariantDataConverter createArrayConverter(
            AvroToVariantDataConverter elementConverter) {
        return (avroObject) -> {
            List<?> list = (List<?>) avroObject;
            VariantBuilder.VariantArrayBuilder variantArrayBuilder = SHARED_BUILDER.array();

            for (Object item : list) {
                Variant convertedItem = elementConverter.convert(item);
                variantArrayBuilder.add(convertedItem);
            }

            return variantArrayBuilder.build();
        };
    }

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Replace the unsupported construct in the schema: fixed -> bytes, enum -> string, before conversion.
  2. Pre-process the schema/data with a mapper that normalizes exotic types, then convert to Variant.
  3. Track/patch flink-avro for the missing type support if it is a type the Variant spec allows.

Example fix

// before
{"name":"id","type":{"type":"fixed","name":"Id16","size":16}}

// after
{"name":"id","type":"bytes"}
Defensive patterns

Strategy: validation

Validate before calling

static void validateVariantConvertible(Schema s) {
    Schema.Type t = s.getType();
    if (t == Schema.Type.FIXED) {
        throw new IllegalArgumentException("FIXED not convertible to VARIANT: " + s.getName());
    }
    s.getFields().forEach(f -> validateVariantConvertible(f.schema())); // recurse records
}

Prevention

When it happens

Trigger: Converting to VARIANT an Avro schema containing a schema type with no case in this converter's switch (e.g. fixed bytes or enum, per current coverage).

Common situations: Feeding Avro schemas with fixed(16) fields (UUIDs, hashes, decimal) or enum fields into the Variant conversion path; assuming all Avro types are Variant-compatible.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/94b9d695affb326d. Report an issue: GitHub.