{"record":{"id":"547041b56cbca053","repo":"apache/beam","slug":"s-expects-a-single-s-tagged-pcollection-row-input","errorCode":null,"errorMessage":"%s expects a single %s tagged PCollection<Row> input","messagePattern":"(.+?) expects a single (.+?) tagged PCollection<Row> input","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/file-schema-transform/src/main/java/org/apache/beam/sdk/io/fileschematransform/FileWriteSchemaTransformProvider.java","lineNumber":114,"sourceCode":"\n  /**\n   * A {@link PTransform} that converts a {@link PCollectionRowTuple} of {@link\n   * #inputCollectionNames()} tagged {@link Row}s into a {@link PCollectionRowTuple} of {@link\n   * #outputCollectionNames()} tagged {@link Row}s.\n   */\n  static class FileWriteSchemaTransform extends SchemaTransform {\n\n    final FileWriteSchemaTransformConfiguration configuration;\n\n    FileWriteSchemaTransform(FileWriteSchemaTransformConfiguration configuration) {\n      validateConfiguration(configuration);\n      this.configuration = configuration;\n    }\n\n    @Override\n    public PCollectionRowTuple expand(PCollectionRowTuple input) {\n      if (input.getAll().isEmpty() || input.getAll().size() > 1) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"%s expects a single %s tagged PCollection<Row> input\",\n                FileWriteSchemaTransform.class.getName(), INPUT_TAG));\n      }\n\n      PCollection<Row> rowInput = input.get(INPUT_TAG);\n\n      PTransform<PCollection<Row>, PCollectionTuple> transform =\n          getProvider().buildTransform(configuration, rowInput.getSchema());\n\n      PCollectionTuple files = rowInput.apply(\"Write Rows\", transform);\n      PCollection<Row> output =\n          files\n              .get(RESULT_TAG)\n              .apply(\n                  \"Filenames to Rows\",\n                  MapElements.into(rows())\n                      .via(","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/file-schema-transform/src/main/java/org/apache/beam/sdk/io/fileschematransform/FileWriteSchemaTransformProvider.java#L96-L132","documentation":"FileWriteSchemaTransform.expand requires exactly one input PCollection<Row>, tagged with the transform's INPUT_TAG, inside the PCollectionRowTuple. If the tuple is empty or contains more than one tagged collection, it throws IllegalArgumentException. This guards the transform against ambiguous or missing row input.","triggerScenarios":"Applying FileWriteSchemaTransform via SchemaTransform providers with a PCollectionRowTuple that has zero tagged PCollections or multiple tags (e.g. feeding output of a multi-output transform without selecting one tag).","commonSituations":"Wiring the wrong transform output (multi-output PCollectionTuple) into the write transform; forgetting to .get() a specific tag before applying; building the tuple programmatically without adding the INPUT_TAG entry.","solutions":["Select exactly one output tag from the producing transform before applying FileWriteSchemaTransform","Ensure the input tag matches the expected INPUT_TAG for the write transform","Convert your PCollection<Row> into a single-entry PCollectionRowTuple: PCollectionRowTuple.of(INPUT_TAG, rows)","Log input.getAll().keySet() before expand to debug what tags are present"],"exampleFix":"// before\nPCollectionRowTuple tuple = PCollectionRowTuple.of(\"rows\", rows)\n    .apply(FileWriteSchemaTransform...); // wrong tag\n// after\nPCollectionRowTuple.of(INPUT_TAG, rows)\n    .apply(FileWriteSchemaTransform...);","handlingStrategy":"validation","validationCode":"if (tuple.getAll().size() != 1 || !tuple.getAll().containsKey(INPUT_TAG)) {\n  throw new IllegalArgumentException(\"FileWriteSchemaTransform needs exactly one \" + INPUT_TAG + \" tagged PCollection<Row>\");\n}","typeGuard":null,"tryCatchPattern":"if (input.getAll().size() != 1) {\n  throw new IllegalStateException(\"Wire exactly one \" + INPUT_TAG + \" PCollection<Row> into FileWriteSchemaTransform; got: \"\n      + input.getAll().keySet());\n}","preventionTips":["Always construct input tuples with PCollectionRowTuple.of(INPUT_TAG, rows)","When consuming multi-output transforms, select a single named output first","Add an assert in the composing code that tuple.getAll().keySet() equals Set.of(INPUT_TAG)"],"tags":["java","beam","schema-transform","argument-validation"],"backgroundTag":"missing-required-argument","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"}