apache/beam · error · RuntimeException

Does not support converting DECIMAL type value

Error message

Does not support converting DECIMAL type value

What it means

Thrown as RuntimeException from convertAvroPrimitiveTypes when the Beam field type is DECIMAL but the code path went through the primitive converter instead of convertAvroNumeric. DECIMAL requires Avro 'bytes' with a decimal logical type handled specially; reaching the primitive switch with DECIMAL means the value arrived in a form this converter does not support.

Source

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

  private static @Nullable Object convertAvroPrimitiveTypes(TypeName beamType, Object value) {
    switch (beamType) {
      case BYTE:
        return ((Long) value).byteValue();
      case INT16:
        return ((Long) value).shortValue();
      case INT32:
        return ((Long) value).intValue();
      case INT64:
        return value; // Long
      case FLOAT:
        return ((Double) value).floatValue();
      case DOUBLE:
        return value; // Double
      case BOOLEAN:
        return value; // Boolean
      case DECIMAL:
        throw new RuntimeException("Does not support converting DECIMAL type value");
      case STRING:
        return convertAvroString(value);
      case BYTES:
        return convertAvroBytes(value);
      default:
        throw new RuntimeException(beamType + " is not primitive type.");
    }
  }

  private static @Nullable Object convertAvroString(@Nullable Object value) {
    if (value == null) {
      return null;
    } else if (value instanceof Utf8) {
      return ((Utf8) value).toString();
    } else if (value instanceof String) {
      return value;
    } else {
      throw new RuntimeException(

View on GitHub (pinned to 12126d8942)

Solutions

  1. Upgrade Beam: newer versions route DECIMAL through convertAvroNumeric and support nested NUMERIC conversion.
  2. Ensure the Avro schema carries the decimal logical type so the DECIMAL branch (convertAvroNumeric) is taken, not the primitive one.
  3. Change the Beam field type to STRING or BYTES and decode the decimal yourself.
  4. If using a custom PassThroughLogicalType, set its base type to BYTES and convert to BigDecimal manually after conversion.

Example fix

// before
FieldType f = FieldType.STRING; // then manual parse of NUMERIC
// after
FieldType f = FieldType.DECIMAL; // converted via convertAvroNumeric
Defensive patterns

Strategy: validation

Validate before calling

// Java: ensure DECIMAL fields don't route through the primitive converter; keep them as top-level FieldType.DECIMAL with a proper avro decimal logical type
schema.getFields().forEach(f -> {
  if (f.getType().getTypeName() == TypeName.DECIMAL) {
    // requires avro bytes + decimal logical type; verify upstream schema
  }
});

Try / catch

try { value = convertAvroFormat(field, v, opts); } catch (RuntimeException e) { if (e.getMessage().equals("Does not support converting DECIMAL type value")) { // decode BigDecimal from avro bytes manually } throw e; }

Prevention

When it happens

Trigger: An Avro value being converted for a Beam DECIMAL field hits convertAvroPrimitiveTypes — e.g. via PassThroughLogicalType delegating a base type of DECIMAL, or nested/array elements routed through the primitive path, where the decimal bytes conversion (convertAvroNumeric) is unavailable.

Common situations: BigQuery NUMERIC/BIGNUMERIC columns inside custom logical types or passthrough wrappers; older Beam versions where nested decimal handling was incomplete; numeric fields nested in ARRAY/RECORD converted via the primitive branch.

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/d2295ad336dc9c4d. Report an issue: GitHub.