apache/beam · error · RuntimeException

Unsupported type <elementType.getType()>

Error message

Unsupported type <elementType.getType()>

What it means

fieldDescriptorFromAvroField maps Avro types to BigQuery TableFieldSchema types; when an Avro logical or primitive type has no mapping (PRIMITIVE_TYPES lookup returns null and no logical-type mapping applies), it throws RuntimeException 'Unsupported type X'.

Source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/AvroGenericRecordToStorageApiProto.java:416

        }
        break;
      default:
        elementType = TypeWithNullability.create(schema).getType();
        if (TIMESTAMP_NANOS_LOGICAL_TYPE.equals(elementType.getProp("logicalType"))) {
          builder = builder.setType(TableFieldSchema.Type.TIMESTAMP);
          builder.setTimestampPrecision(
              Int64Value.newBuilder().setValue(PICOSECOND_PRECISION).build());
          break;
        } else {
          Optional<LogicalType> logicalType =
              Optional.ofNullable(LogicalTypes.fromSchema(elementType));
          @Nullable
          TableFieldSchema.Type primitiveType =
              logicalType
                  .flatMap(AvroGenericRecordToStorageApiProto::logicalTypes)
                  .orElse(PRIMITIVE_TYPES.get(elementType.getType()));
          if (primitiveType == null) {
            throw new RuntimeException("Unsupported type " + elementType.getType());
          }
          // a scalar will be required by default, if defined as part of union then
          // caller will set nullability requirements
          builder = builder.setType(primitiveType);
          // parametrized types
          if (logicalType.isPresent() && logicalType.get().getName().equals("decimal")) {
            LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) logicalType.get();
            int precision = decimal.getPrecision();
            int scale = decimal.getScale();
            if (!(precision == 38 && scale == 9) // NUMERIC
                && !(precision == 77 && scale == 38) // BIGNUMERIC
            ) {
              // parametrized type
              builder = builder.setPrecision(precision);
              if (scale != 0) {
                builder = builder.setScale(scale);
              }
            }

View on GitHub (pinned to 12126d8942)

Solutions

  1. Change the Avro field to a supported type or standard logical type (e.g. decimal with proper precision/scale)
  2. Update Beam to a version whose logicalTypes map supports the type
  3. Pre-convert unsupported types to strings/bytes in the Avro schema

Example fix

// before
{"type":"bytes","logicalType":"duration"} // unsupported logical type
// after
{"type":"long"} // or a supported logical type like decimal
Defensive patterns

Strategy: validation

Validate before calling

for (org.apache.avro.Schema.Field f : avroSchema.getFields()) { org.apache.avro.Schema t = unwrapUnion(f.schema()); if (t.getLogicalType() != null && !SUPPORTED_LOGICALS.contains(t.getLogicalType().getName())) throw new IllegalStateException("unsupported logical type " + t.getLogicalType().getName() + " on " + f.name()); }

Type guard

boolean avroTypeSupported(org.apache.avro.Schema s) { org.apache.avro.LogicalType lt = s.getLogicalType(); return lt == null || Set.of("decimal","date","time-millis","timestamp-millis").contains(lt.getName()); }

Try / catch

try { protoTableSchema = ...protoTableSchemaFromAvroSchema(...); } catch (RuntimeException e) { if (e.getMessage().startsWith("Unsupported type")) { normalizeSchemaAndRetry(); } else throw e; }

Prevention

When it happens

Trigger: An Avro schema with a logical type not in the logicalTypes map (e.g. an exotic or custom logical type) whose underlying primitive also has no PRIMITIVE_TYPES entry.

Common situations: Producers using newer Avro logical types (duration, custom decimals) that this converter does not recognize; version mismatch between writer schema and converter support.

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


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