{"record":{"id":"c0d752d49e84ace0","repo":"apache/beam","slug":"sessions-is-only-compatible-with-sessions","errorCode":null,"errorMessage":"Sessions is only compatible with Sessions.","messagePattern":"Sessions is only compatible with Sessions\\.","errorType":"exception","errorClass":"IncompatibleWindowException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/Sessions.java","lineNumber":82,"sourceCode":"  @Override\n  public void mergeWindows(MergeContext c) throws Exception {\n    MergeOverlappingIntervalWindows.mergeWindows(c);\n  }\n\n  @Override\n  public Coder<IntervalWindow> windowCoder() {\n    return IntervalWindow.getCoder();\n  }\n\n  @Override\n  public boolean isCompatible(WindowFn<?, ?> other) {\n    return other instanceof Sessions;\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              Sessions.class.getSimpleName(), Sessions.class.getSimpleName()));\n    }\n  }\n\n  @Override\n  public TypeDescriptor<IntervalWindow> getWindowTypeDescriptor() {\n    return TypeDescriptor.of(IntervalWindow.class);\n  }\n\n  @Override\n  public WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn() {\n    throw new UnsupportedOperationException(\"Sessions is not allowed in side inputs\");\n  }\n\n  public Duration getGapDuration() {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/Sessions.java#L64-L100","documentation":"Sessions windowing can only be combined with other Sessions windowing that uses identical gap duration semantics; verifyCompatibility enforces this during pipeline construction when two windowfns must interact (e.g. merging side inputs or composite transforms). Passing any non-Sessions WindowFn (or mismatched Sessions) throws IncompatibleWindowException with this message.","triggerScenarios":"Calling Sessions.verifyCompatibility(other) where other is not a Sessions instance, e.g. Window.into(Sessions.withGapDuration(...)) combined in a transform with FixedWindows/SlidingWindows inputs.","commonSituations":"Joining or flattening PCollections windowed differently; applying a composite transform that requires uniform windowing; mistakenly applying Window.into() twice with different windowfns on the same stream.","solutions":["Apply Window.into(Sessions.withGapDuration(...)) consistently to all involved PCollections","Use Window.descending()/re-windowing: re-window inputs to Sessions before combining","If a fixed/sliding view is needed, perform the operation per-session via Window.into matching both sides"],"exampleFix":"// before\nPCollection<T> a = ...apply(Window.into(FixedWindows.of(_minutes(1))));\nPCollection<T> b = ...apply(Window.into(Sessions.withGapDuration(_minutes(5))));\nKeyedPCollectionTuple.of(...) // IncompatibleWindowException\n// after\nPCollection<T> a2 = a.apply(Window.into(Sessions.withGapDuration(_minutes(5))));","handlingStrategy":"validation","validationCode":"if (!(windowFnA instanceof Sessions) || !(windowFnB instanceof Sessions)) throw new IllegalArgumentException(\"Both PCollections must use Sessions windowing\");","typeGuard":"boolean sessionsCompatible(WindowFn<?,?> a, WindowFn<?,?> b) { return a instanceof Sessions && b instanceof Sessions; }","tryCatchPattern":"try { pipeline.apply(combine); } catch (IncompatibleWindowException e) { reWindowAllInputs(Sessions.withGapDuration(gap)); }","preventionTips":["Centralize windowing configuration so all branches share one WindowFn","Re-window explicitly before join/flatten/coGroup","Add a pipeline-construction assertion that all combined PCollections use the same windowfn"],"tags":["java","apache-beam","windowing","sessions","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"}