{"record":{"id":"d1eac3ad0bb986e6","repo":"apache/beam","slug":"only-slidingwindows-objects-with-the-same-size-period-and","errorCode":null,"errorMessage":"Only SlidingWindows objects with the same size, period and offset are compatible.","messagePattern":"Only SlidingWindows objects with the same size, period and offset are compatible\\.","errorType":"exception","errorClass":"IncompatibleWindowException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/SlidingWindows.java","lineNumber":151,"sourceCode":"        return new IntervalWindow(new Instant(lastStart + period.getMillis()), size);\n      }\n    };\n  }\n\n  @Override\n  public boolean isCompatible(WindowFn<?, ?> other) {\n    return equals(other);\n  }\n\n  @Override\n  public boolean assignsToOneWindow() {\n    return !this.period.isShorterThan(this.size);\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              \"Only %s objects with the same size, period and offset are compatible.\",\n              SlidingWindows.class.getSimpleName()));\n    }\n  }\n\n  @Override\n  public void populateDisplayData(DisplayData.Builder builder) {\n    super.populateDisplayData(builder);\n    builder\n        .add(DisplayData.item(\"size\", size).withLabel(\"Window Size\"))\n        .add(DisplayData.item(\"period\", period).withLabel(\"Window Period\"))\n        .add(DisplayData.item(\"offset\", offset).withLabel(\"Window Start Offset\"));\n  }\n\n  /** Return the last start of a sliding window that contains the timestamp. */\n  private long lastStartFor(Instant timestamp) {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/SlidingWindows.java#L133-L169","documentation":"SlidingWindows.isCompatible returns true only when another WindowFn is also a SlidingWindows with equal period, size and offset. verifyCompatibility throws IncompatibleWindowException with this message when the check fails, preventing pipelines that would merge or combine incompatible sliding windowings.","triggerScenarios":"Calling verifyCompatibility with a FixedWindows, Sessions, or a SlidingWindows with different size/period/offset — typically during pipeline graph validation of combined transforms.","commonSituations":"Joining streams windowed with different slide periods; a config change altering one side's window parameters but not the other; re-windowing one branch but forgetting the sibling branch.","solutions":["Use identical SlidingWindows.of(size).every(period[, offset]) on all PCollections being combined","Re-window one side with Window.into(theOtherWindowFn) before the join/flatten","Verify both pipeline branches read the same windowing config value"],"exampleFix":"// before\na.apply(Window.into(SlidingWindows.of(minutes(30)).every(minutes(5))))\nb.apply(Window.into(SlidingWindows.of(minutes(60)).every(minutes(5))))\n// after\nb.apply(Window.into(SlidingWindows.of(minutes(30)).every(minutes(5))))","handlingStrategy":"validation","validationCode":"if (!Objects.equals(cfgA.windowSpec(), cfgB.windowSpec())) throw new IllegalArgumentException(\"Branches must use identical SlidingWindows size/period/offset\");","typeGuard":"boolean sameSlidingWindows(WindowFn<?,?> a, WindowFn<?,?> b) { return a instanceof SlidingWindows && b instanceof SlidingWindows && a.isCompatible(b); }","tryCatchPattern":"try { pipeline.apply(join); } catch (IncompatibleWindowException e) { b = b.apply(Window.into(slidingA)); }","preventionTips":["Drive windowing of all combined PCollections from one config object","Add pre-apply isCompatible checks in shared pipeline helpers","Re-window explicitly at join/flatten boundaries"],"tags":["java","apache-beam","windowing","compatibility"],"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"}