{"record":{"id":"1b81bef6197cfbd7","repo":"apache/beam","slug":"inputs-of-optype-have-different-window-strategy-leftwindow","errorCode":null,"errorMessage":"inputs of ${opType} have different window strategy: ${leftWindow} VS ${rightWindow}","messagePattern":"inputs of (.+?) have different window strategy: (.+?) VS (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSetOperatorRelBase.java","lineNumber":73,"sourceCode":"    this.beamRelNode = beamRelNode;\n    this.opType = opType;\n    this.all = all;\n  }\n\n  @Override\n  public PCollection<Row> expand(PCollectionList<Row> inputs) {\n    checkArgument(\n        inputs.size() == 2,\n        \"Wrong number of arguments to %s: %s\",\n        beamRelNode.getClass().getSimpleName(),\n        inputs);\n    PCollection<Row> leftRows = inputs.get(0);\n    PCollection<Row> rightRows = inputs.get(1);\n\n    WindowFn leftWindow = leftRows.getWindowingStrategy().getWindowFn();\n    WindowFn rightWindow = rightRows.getWindowingStrategy().getWindowFn();\n    if (!leftWindow.isCompatible(rightWindow)) {\n      throw new IllegalArgumentException(\n          \"inputs of \"\n              + opType\n              + \" have different window strategy: \"\n              + leftWindow\n              + \" VS \"\n              + rightWindow);\n    }\n\n    // TODO: We may want to preaggregate the counts first using Group instead of calling CoGroup and\n    // measuring the\n    // iterable size. If on average there are duplicates in the input, this will be faster.\n    final String lhsTag = \"lhs\";\n    final String rhsTag = \"rhs\";\n    PCollection<Row> joined =\n        PCollectionTuple.of(lhsTag, leftRows, rhsTag, rightRows)\n            .apply(\"CoGroup\", CoGroup.join(By.fieldNames(\"*\")));\n    return joined\n        .apply(","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSetOperatorRelBase.java#L55-L91","documentation":"BeamSetOperatorRelBase (UNION/INTERSECT/EXCEPT) requires both input PCollections to use compatible window functions so rows can be aligned element-wise. If left and right WindowFn are not compatible (WindowFn.isCompatible returns false), expand throws IllegalArgumentException describing both strategies.","triggerScenarios":"A UNION (ALL)/INTERSECT/EXCEPT query where one input is windowed differently from the other, e.g. fixed windows on one side and sliding/global windows on the other, or one side unwindowed (global) while the other is windowed.","commonSituations":"Joining a batch PCollection (global window) with a streaming windowed PCollection; mixing window assignments from different sources before a set operation; PCollections built programmatically with mismatched WindowFns.","solutions":["Apply the same WindowFn (and trigger) to both inputs before the set operation, e.g. via Window.into(...) on one or both sides","Re-window one input into the other's windowing using Window.configure() / re-windowing transforms","Ensure neither side accidentally uses the default GlobalWindows when the other is windowed"],"exampleFix":"// before\nPCollection<Row> right = rows.apply(Window.into(FixedWindows.of(Duration.standardMinutes(5))));\nunion = left.apply(SqlTransform...); // left in GlobalWindows\n// after\nleft = left.apply(Window.into(FixedWindows.of(Duration.standardMinutes(5))));\nright = right.apply(Window.into(FixedWindows.of(Duration.standardMinutes(5))));","handlingStrategy":"validation","validationCode":"// Validate window compatibility before the set operation\nWindowFn l = left.getWindowingStrategy().getWindowFn();\nWindowFn r = right.getWindowingStrategy().getWindowFn();\nif (!l.isCompatible(r)) {\n  throw new IllegalArgumentException(\"Re-window both inputs identically before UNION/INTERSECT/EXCEPT\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  result = sqlEnv.sqlQuery(unionQuery).evaluate();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"have different window strategy\")) {\n    inputs = reWindowBothSides(inputs, commonWindowFn);\n    // retry\n  } else throw e;\n}","preventionTips":["Apply the same Window.into(...) to all inputs feeding a set operation","Check getWindowingStrategy() on both PCollections before UNION","Watch for GlobalWindows defaults on batch inputs mixed with windowed streams"],"tags":["sql","windows","set-operator","streaming","beam"],"backgroundTag":"incompatible-source-type","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"}