apache/beam · error · UnsupportedOperationException

Unsupported underlying type for parsing logical type via cod

Error message

Unsupported underlying type for parsing logical type via coder.

What it means

When a logical type value must be decoded via its representation coder, logicalTypeFromProto first reads the raw atomic representation from the proto (INT64, BYTES, etc.). If the stored atomic value's type is none of the supported cases, this UnsupportedOperationException is thrown because Beam cannot feed that representation into the coder's input stream.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaTranslation.java:738

                entry -> fieldValueFromProto(mapKeyType, entry.getKey()),
                entry -> fieldValueFromProto(mapValueType, entry.getValue())));
  }

  /** Converts logical type value from proto using a default type coder. */
  private static Object logicalTypeFromProto(
      FieldType baseType, FieldType inputType, LogicalTypeValue value) {
    try {
      PipedInputStream in = new PipedInputStream();
      DataOutputStream stream = new DataOutputStream(new PipedOutputStream(in));
      switch (baseType.getTypeName()) {
        case INT64:
          stream.writeLong(value.getValue().getAtomicValue().getInt64());
          break;
        case BYTES:
          stream.write(value.getValue().getAtomicValue().getBytes().toByteArray());
          break;
        default:
          throw new UnsupportedOperationException(
              "Unsupported underlying type for parsing logical type via coder.");
      }
      stream.close();
      return SchemaCoderHelpers.coderForFieldType(inputType).decode(in);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

  /** Converts logical type value to a proto using a default type coder. */
  private static LogicalTypeValue logicalTypeToProto(
      FieldType baseType, FieldType inputType, Object value) {
    try {
      PipedInputStream in = new PipedInputStream();
      PipedOutputStream out = new PipedOutputStream(in);
      SchemaCoderHelpers.coderForFieldType(inputType).encode(value, out);
      out.close(); // Close required for toByteArray.
      Object baseObject;

View on GitHub (pinned to 12126d8942)

Solutions

  1. Ensure the logical type's representation type is identical on write and read sides (same Beam version / same representation).
  2. Inspect the stored AtomicTypeValue case and add/upgrade support in your Beam version.
  3. If you control the logical type, change its representation to INT64, DOUBLE, STRING, or BYTES.
  4. Avoid the coder path by registering an explicit LogicalType with proper getArgumentType/getBaseType so the non-coder path is used.

Example fix

// before
@Override
public FieldType getRepresentation() { return FieldType.iterable(FieldType.INT32); } // unsupported via coder path
// after
@Override
public FieldType getRepresentation() { return FieldType.BYTES; }
Defensive patterns

Strategy: type-guard

Validate before calling

FieldType rep = logicalType.getRepresentation(); if (!(rep.getTypeName().isPrimitiveType())) throw new IllegalArgumentException("logical type representation must be a primitive for coder path");

Type guard

boolean coderSafeRepresentation(FieldType rep) { switch (rep.getTypeName()) { case INT64: case DOUBLE: case STRING: case BYTES: return true; default: return false; } }

Try / catch

try { decodeValue(...); } catch (UnsupportedOperationException e) { if (e.getMessage().contains("Unsupported underlying type for parsing logical type")) { /* fix representation type */ } else { throw e; } }

Prevention

When it happens

Trigger: fieldValueFromProto → logicalTypeFromProto encounters a LogicalTypeValue whose value's AtomicTypeValue case is not INT64, DOUBLE, STRING, or BYTES while decoding through the coder-based path.

Common situations: Logical type representation changed between writer and reader versions (representation type mismatch); proto built by another language/SDK writing a different atomic case; hand-crafted protos in tests.

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