apache/beam · error · UnsupportedOperationException

+fieldType.getTypeName()+ is not supported

Error message

+fieldType.getTypeName()+ is not supported

What it means

toPrettyFieldTypeString renders a FieldType as an indented pretty string but only implements the known TypeName branches (primitives, collections, maps, rows). Any other TypeName falls into the default branch and throws UnsupportedOperationException. This is a rendering limitation, not a data problem — the field type itself is valid, just not printable by this helper.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/SchemaUtils.java:219

      case LOGICAL_TYPE:
        {
          Schema.FieldType baseType =
              Objects.requireNonNull(fieldType.getLogicalType()).getBaseType();
          StringBuilder sb = new StringBuilder();
          sb.append("<")
              .append(toFieldTypeNameString(fieldType))
              .append("(")
              .append(fieldType.getLogicalType().getIdentifier())
              .append(")> {\n");
          sb.append(nextPrefix)
              .append("<base>: ")
              .append(toPrettyFieldTypeString(baseType, nextPrefix))
              .append("\n");
          sb.append(prefix).append("}");
          return sb.toString();
        }
      default:
        throw new UnsupportedOperationException(fieldType.getTypeName() + " is not supported");
    }
  }

  static String toPrettyOptionsString(Schema.Options options, String prefix) {
    String nextPrefix = prefix + INDENT;
    StringBuilder sb = new StringBuilder();
    sb.append("{\n");
    for (String optionName : options.getOptionNames()) {
      sb.append(nextPrefix)
          .append(optionName)
          .append(" = ")
          .append(
              toPrettyFieldValueString(
                  options.getType(optionName), options.getValue(optionName), nextPrefix))
          .append("\n");
    }
    sb.append(prefix).append("}");
    return sb.toString();

View on GitHub (pinned to 12126d8942)

Solutions

  1. Upgrade Beam so toPrettyFieldTypeString covers the newer/logical TypeName.
  2. Replace the offending field type with a printable one before pretty-printing, or print with Schema.toString().
  3. Write a custom formatter that handles the unhandled TypeName via getLogicalType()/getTypeName().
  4. Catch UnsupportedOperationException and fall back to fieldType.toString() for the unsupported branches.

Example fix

// before
String pretty = SchemaUtils.toPrettySchemaString(schemaWithLogicalTypes); // throws UnsupportedOperationException
// after
try {
  String pretty = SchemaUtils.toPrettySchemaString(schemaWithLogicalTypes);
} catch (UnsupportedOperationException e) {
  String pretty = schemaWithLogicalTypes.toString(); // fallback rendering
}
Defensive patterns

Strategy: try-catch

Validate before calling

boolean allPrintable = schema.getFields().stream()
    .allMatch(f -> switch (f.getType().getTypeName()) {
      case BYTE, INT16, INT32, INT64, FLOAT, DOUBLE, BOOLEAN, STRING, ARRAY,
           ITERABLE, MAP, ROW -> true;
      default -> false;
    });

Type guard

boolean isPrettyPrintable(FieldType t) {
  return t.getTypeName() != TypeName.LOGICAL_TYPE; // adjust per your Beam version's switch coverage
}

Try / catch

try {
  String pretty = SchemaUtils.toPrettySchemaString(schema);
} catch (UnsupportedOperationException e) {
  LOG.warn("Pretty printer lacks support for a type; using toString(): {}", e.getMessage());
  String pretty = schema.toString();
}

Prevention

When it happens

Trigger: Calling SchemaUtils.toPrettySchemaString(schema) or toPrettyFieldTypeString(fieldType) on a schema containing a field whose TypeName is not handled by the switch — historically e.g. DATETIME / LOGICAL_TYPE / newer TypeName additions in Beam versions newer than this method's implementation.

Common situations: Pretty-printing a schema containing logical types (timestamps) or a TypeName added in a newer Beam release than the code calling this helper; dumping a SQL-derived schema with unhandled types.

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