apache/beam · error · RuntimeException

Parameter has no schema and the input is not a simple type.

Error message

Parameter has no schema and the input is not a simple type.

What it means

withUnboxPrimitiveParameter converts a schema'd input to a single primitive parameter of a DoFn; it requires that the selected output schema have exactly one field. If the selection yields zero or multiple fields, the parameter cannot be unboxed to a single simple type and a RuntimeException is thrown while building DoFnSchemaInformation.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/DoFnSchemaInformation.java:133

  /**
   * Specified a parameter that is a selection from an input schema (specified using FieldAccess).
   * This method is called when the input parameter is a Java type that does not itself have a
   * schema, e.g. long, or String. In this case we expect the selection predicate to return a
   * single-field row with a field of the output type.
   *
   * @param inputCoder The coder for the ParDo's input elements.
   * @param selectDescriptor The descriptor describing which field to select.
   * @param selectOutputSchema The schema of the selected parameter.
   * @param elementT The type of the method's input parameter.
   * @return
   */
  DoFnSchemaInformation withUnboxPrimitiveParameter(
      SchemaCoder inputCoder,
      FieldAccessDescriptor selectDescriptor,
      Schema selectOutputSchema,
      TypeDescriptor<?> elementT) {
    if (selectOutputSchema.getFieldCount() != 1) {
      throw new RuntimeException("Parameter has no schema and the input is not a simple type.");
    }
    FieldType fieldType = selectOutputSchema.getField(0).getType();
    if (fieldType.getTypeName().isCompositeType()) {
      throw new RuntimeException("Parameter has no schema and the input is not a primitive type.");
    }

    List<SerializableFunction<?, ?>> converters =
        ImmutableList.<SerializableFunction<?, ?>>builder()
            .addAll(getElementConverters())
            .add(
                UnboxingConversionFunction.of(
                    inputCoder.getSchema(),
                    inputCoder.getToRowFunction(),
                    selectDescriptor,
                    selectOutputSchema,
                    elementT))
            .build();

View on GitHub (pinned to 12126d8942)

Solutions

  1. Make the DoFn parameter type match a single-field selection, or select exactly one field (FieldAccessDescriptor.withFieldNames("oneField"))
  2. Change the parameter to the full row type (Row or the schema class) instead of a primitive
  3. Use withUnboxPrimitiveParameter-compatible transforms: ensure selectOutputSchema has exactly one field before wiring the DoFn

Example fix

// before (two fields selected, primitive param)
@ProcessElement public void process(@Element Integer value) {...}
// after
@ProcessElement public void process(@Element Row row) { Integer value = row.getInt32("myField"); ... }
Defensive patterns

Strategy: validation

Validate before calling

if (selectOutputSchema.getFieldCount() != 1) {
  throw new IllegalArgumentException("Expected single-field selection for primitive DoFn parameter");
}

Try / catch

try {
  DoFnSchemaInformation info = DoFnSchemaInformation.getDoFnSchemaInformation(doFn, inputCoder);
} catch (RuntimeException e) {
  // fall back to full Row parameter binding
}

Prevention

When it happens

Trigger: Using a @ProcessElement method whose parameter is a simple type (e.g. Integer, String) while the input PCollection has a SchemaCoder whose selection (FieldAccessDescriptor) resolves to a schema with a field count != 1.

Common situations: Mismatches between an annotated DoFn parameter type and a Row/schema'd input; applying schema transforms (e.g. MapElements with a field selection) that produce multiple fields to a DoFn expecting one primitive.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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