apache/beam · error · UnsupportedOperationException

${fieldType}

Error message

${fieldType}

What it means

JavaRowUdf maps Schema.FieldType values to Java classes (via primitive maps or Row.class for nested rows). typeFromFieldType throws UnsupportedOperationException when it encounters a field type that is neither a known primitive/logical type nor a row with a schema — e.g. arrays, maps, or exotic logical types unsupported by the expression compiler.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/transforms/providers/JavaRowUdf.java:343

          .put(Schema.TypeName.INT32, int.class)
          .put(Schema.TypeName.INT64, long.class)
          .put(Schema.TypeName.FLOAT, float.class)
          .put(Schema.TypeName.DOUBLE, double.class)
          .put(Schema.TypeName.BOOLEAN, boolean.class)
          .put(Schema.TypeName.BYTES, byte[].class)
          .put(Schema.TypeName.STRING, String.class)
          .put(Schema.TypeName.DECIMAL, BigDecimal.class)
          .build();

  private static Type typeFromFieldType(Schema.FieldType fieldType) {
    Map<Schema.TypeName, Type> primitivesMap =
        fieldType.getNullable() ? NULLABLE_PRIMITIVES : NON_NULLABLE_PRIMITIVES;
    if (primitivesMap.containsKey(fieldType.getTypeName())) {
      return primitivesMap.get(fieldType.getTypeName());
    } else if (fieldType.getRowSchema() != null) {
      return Row.class;
    } else {
      throw new UnsupportedOperationException(fieldType.toString());
    }
  }
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Restrict the UDF input schema to primitive and row-typed fields
  2. Flatten or explode collection fields before applying the UDF
  3. Extend the primitive maps or handle the FieldType case upstream in your own fork
  4. Check fieldType.getTypeName() against supported types before invoking the transform

Example fix

// before
// schema field: tags ARRAY<STRING> passed into a row UDF
// after
// explode/flatten 'tags' first, or exclude it from the UDF input schema
Defensive patterns

Strategy: validation

Validate before calling

for (Schema.Field f : inputSchema.getFields()) {
  Schema.FieldType t = f.getType();
  if (PRIMITIVES.containsKey(t.getTypeName()) || t.getRowSchema() != null)
    throw new IllegalArgumentException("Unsupported UDF field type: " + t);
}

Try / catch

try { createUdf(cfg); } catch (UnsupportedOperationException e) { /* fall back to DoFn-based UDF */ }

Prevention

When it happens

Trigger: createFunctionFromExpression compiles a generated class whose generated method signature includes a parameter or return type resolved through typeFromFieldType, and the input schema contains a field of an unmapped FieldType (e.g. ARRAY, MAP, ITERABLE, or a logical type without a row schema).

Common situations: Applying a row UDF to a schema containing collection or map fields; using a custom logical type the primitive maps don't cover.

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