{"record":{"id":"0f1d0708465bb6ce","repo":"apache/beam","slug":"parameter-has-no-schema-and-the-input-is-not-a-simple-type","errorCode":null,"errorMessage":"Parameter has no schema and the input is not a simple type.","messagePattern":"Parameter has no schema and the input is not a simple type\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/DoFnSchemaInformation.java","lineNumber":133,"sourceCode":"  /**\n   * Specified a parameter that is a selection from an input schema (specified using FieldAccess).\n   * This method is called when the input parameter is a Java type that does not itself have a\n   * schema, e.g. long, or String. In this case we expect the selection predicate to return a\n   * single-field row with a field of the output type.\n   *\n   * @param inputCoder The coder for the ParDo's input elements.\n   * @param selectDescriptor The descriptor describing which field to select.\n   * @param selectOutputSchema The schema of the selected parameter.\n   * @param elementT The type of the method's input parameter.\n   * @return\n   */\n  DoFnSchemaInformation withUnboxPrimitiveParameter(\n      SchemaCoder inputCoder,\n      FieldAccessDescriptor selectDescriptor,\n      Schema selectOutputSchema,\n      TypeDescriptor<?> elementT) {\n    if (selectOutputSchema.getFieldCount() != 1) {\n      throw new RuntimeException(\"Parameter has no schema and the input is not a simple type.\");\n    }\n    FieldType fieldType = selectOutputSchema.getField(0).getType();\n    if (fieldType.getTypeName().isCompositeType()) {\n      throw new RuntimeException(\"Parameter has no schema and the input is not a primitive type.\");\n    }\n\n    List<SerializableFunction<?, ?>> converters =\n        ImmutableList.<SerializableFunction<?, ?>>builder()\n            .addAll(getElementConverters())\n            .add(\n                UnboxingConversionFunction.of(\n                    inputCoder.getSchema(),\n                    inputCoder.getToRowFunction(),\n                    selectDescriptor,\n                    selectOutputSchema,\n                    elementT))\n            .build();\n","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/DoFnSchemaInformation.java#L115-L151","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Make the DoFn parameter type match a single-field selection, or select exactly one field (FieldAccessDescriptor.withFieldNames(\"oneField\"))","Change the parameter to the full row type (Row or the schema class) instead of a primitive","Use withUnboxPrimitiveParameter-compatible transforms: ensure selectOutputSchema has exactly one field before wiring the DoFn"],"exampleFix":"// before (two fields selected, primitive param)\n@ProcessElement public void process(@Element Integer value) {...}\n// after\n@ProcessElement public void process(@Element Row row) { Integer value = row.getInt32(\"myField\"); ... }","handlingStrategy":"validation","validationCode":"if (selectOutputSchema.getFieldCount() != 1) {\n  throw new IllegalArgumentException(\"Expected single-field selection for primitive DoFn parameter\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  DoFnSchemaInformation info = DoFnSchemaInformation.getDoFnSchemaInformation(doFn, inputCoder);\n} catch (RuntimeException e) {\n  // fall back to full Row parameter binding\n}","preventionTips":["Keep @Element primitive parameters aligned with single-field schema selections","Prefer Row-typed parameters for multi-field inputs"],"tags":["apache-beam","java","schema","dofn"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}