{"record":{"id":"1949caa7225fdfd5","repo":"apache/beam","slug":"globalwindows-is-only-compatible-with-globalwindows","errorCode":null,"errorMessage":"GlobalWindows is only compatible with GlobalWindows.","messagePattern":"GlobalWindows is only compatible with GlobalWindows\\.","errorType":"exception","errorClass":"IncompatibleWindowException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/GlobalWindows.java","lineNumber":53,"sourceCode":"public class GlobalWindows extends NonMergingWindowFn<Object, GlobalWindow> {\n\n  private static final Collection<GlobalWindow> GLOBAL_WINDOWS =\n      Collections.singletonList(GlobalWindow.INSTANCE);\n\n  @Override\n  public Collection<GlobalWindow> assignWindows(AssignContext c) {\n    return GLOBAL_WINDOWS;\n  }\n\n  @Override\n  public boolean isCompatible(WindowFn<?, ?> o) {\n    return o instanceof GlobalWindows;\n  }\n\n  @Override\n  public void verifyCompatibility(WindowFn<?, ?> other) throws IncompatibleWindowException {\n    if (!this.isCompatible(other)) {\n      throw new IncompatibleWindowException(\n          other,\n          String.format(\n              \"%s is only compatible with %s.\",\n              GlobalWindows.class.getSimpleName(), GlobalWindows.class.getSimpleName()));\n    }\n  }\n\n  @Override\n  public Coder<GlobalWindow> windowCoder() {\n    return GlobalWindow.Coder.INSTANCE;\n  }\n\n  @Override\n  public WindowMappingFn<GlobalWindow> getDefaultWindowMappingFn() {\n    return new AutoValue_GlobalWindows_GlobalWindowMappingFn();\n  }\n\n  @AutoValue","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/GlobalWindows.java#L35-L71","documentation":"GlobalWindows.verifyCompatibility throws IncompatibleWindowException when a GlobalWindows-windowed PCollection is merged with a PCollection using any other WindowFn. Beam requires both sides of a cross-source grouping to use the same window function, and GlobalWindows is only compatible with itself.","triggerScenarios":"CoGroupByKey/Flatten between a PCollection with Window.into(GlobalWindows()) and one windowed with FixedWindows/SlidingWindows/CalendarWindows (or vice versa).","commonSituations":"Joining an unbounded stream that was explicitly set to global windows against a calendar/fixed-windowed side input; forgetting that some transforms (e.g. after certain aggregations) leave GlobalWindows while the other input keeps event-time windows.","solutions":["Re-window one PCollection to match the other (either both GlobalWindows or both the same event-time WindowFn) before merging.","If event-time alignment is required, window the global side with the same WindowFn as the other input.","If global windows are correct, convert the other input via Window.into(GlobalWindows()) (and reassign timestamps as needed) before the join.","Catch IncompatibleWindowException in pipeline setup to surface the mismatch early."],"exampleFix":"// before\nPCollection<A> a = inA.apply(Window.into(FixedWindows.of(MINUTES_5)));\nPCollection<B> b = inB.apply(Window.into(GlobalWindows()));\nKeyedPCollectionTuple.of(t1, a).and(t2, b).apply(CoGroupByKey.create()); // throws\n// after\nPCollection<B> b2 = inB.apply(Window.into(FixedWindows.of(MINUTES_5)));\nKeyedPCollectionTuple.of(t1, a).and(t2, b2).apply(CoGroupByKey.create());","handlingStrategy":"validation","validationCode":"public static void requireSameWindowing(WindowFn<?, ?> a, WindowFn<?, ?> b) throws IncompatibleWindowException {\n  a.verifyCompatibility(b); // throws if GlobalWindows is merged with any other WindowFn\n}","typeGuard":"boolean isGlobal(WindowFn<?, ?> fn) { return fn instanceof GlobalWindows; }","tryCatchPattern":"try {\n  gw.verifyCompatibility(otherFn);\n} catch (IncompatibleWindowException e) {\n  // re-window otherFn's PCollection to GlobalWindows or the matching event-time WindowFn\n}","preventionTips":["Decide upfront whether merges happen in global or event-time windows and standardize.","Remember GlobalWindows is only compatible with itself; convert one side explicitly.","After aggregations that emit GlobalWindows, re-window before joining with windowed inputs.","Add pipeline-construction asserts calling verifyCompatibility."],"tags":["java","apache-beam","windowing","incompatibility"],"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-20T03:17:13.778Z"}