{"record":{"id":"3f1e0a71ed02adc5","repo":"apache/beam","slug":"pcollections-come-from-different-pipelines-3f1e0a","errorCode":null,"errorMessage":"PCollections come from different Pipelines","messagePattern":"PCollections come from different Pipelines","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionRowTuple.java","lineNumber":151,"sourceCode":"      PCollection<Row> pc5) {\n    return of(tag1, pc1, tag2, pc2, tag3, pc3, tag4, pc4).and(tag5, pc5);\n  }\n\n  // To create a PCollectionRowTuple with more than five inputs, use the and() builder method.\n\n  /**\n   * Returns a new {@link PCollectionRowTuple} that has each {@link PCollection} and tag of this\n   * {@link PCollectionRowTuple} plus the given {@link PCollection} associated with the given tag.\n   *\n   * <p>The given tag should not already be mapped to a {@link PCollection} in this {@link\n   * PCollectionRowTuple}.\n   *\n   * <p>Each {@link PCollection} in the resulting {@link PCollectionRowTuple} must be part of the\n   * same {@link Pipeline}.\n   */\n  public PCollectionRowTuple and(String tag, PCollection<Row> pc) {\n    if (pc.getPipeline() != pipeline) {\n      throw new IllegalArgumentException(\"PCollections come from different Pipelines\");\n    }\n\n    return new PCollectionRowTuple(\n        pipeline,\n        new ImmutableMap.Builder<String, PCollection<Row>>()\n            .putAll(pcollectionMap)\n            .put(tag, pc)\n            .build());\n  }\n\n  /**\n   * Returns whether this {@link PCollectionRowTuple} contains a {@link PCollection} with the given\n   * tag.\n   */\n  public boolean has(String tag) {\n    return pcollectionMap.containsKey(tag);\n  }\n","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/values/PCollectionRowTuple.java#L133-L169","documentation":"PCollectionRowTuple.and(String, PCollection<Row>) requires the added PCollection to belong to the tuple's Pipeline; on mismatch it throws IllegalArgumentException because Beam cannot mix PCollections from different Pipelines in one tuple.","triggerScenarios":"Adding a PCollection<Row> produced by a different Pipeline instance to an existing PCollectionRowTuple via and(tag, pc).","commonSituations":"Merging Row outputs from separately built Pipelines (e.g. BigQuery reads in different test setups); creating a new Pipeline inside a helper that contributes to an existing tuple.","solutions":["Ensure the PCollection was created by the same Pipeline as the tuple","Pass the tuple's Pipeline into the code that produces the PCollection<Row>","Rebuild the tuple entirely from PCollections of one Pipeline"],"exampleFix":"// before\ntuple.and(\"rows\", pcFromOtherPipeline); // throws\n// after\nPCollection<Row> rows = tuple.getPipeline().apply(...);\ntuple.and(\"rows\", rows);","handlingStrategy":"validation","validationCode":"if (pc.getPipeline() != tuple.getPipeline()) { throw new IllegalArgumentException(\"wrong pipeline\"); }","typeGuard":"boolean samePipeline(PCollection<?> pc, PCollectionRowTuple t) { return pc.getPipeline() == t.getPipeline(); }","tryCatchPattern":"try { return tuple.and(tag, pc); } catch (IllegalArgumentException e) { /* rebuild pc on tuple's pipeline */ }","preventionTips":["Obtain new PCollections from tuple.getPipeline()","Pass Pipeline explicitly to Row-producing helpers","Keep test pipelines separate from production ones"],"tags":["java","apache-beam","pipeline","illegal-argument"],"backgroundTag":"invalid-argument-value","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"}