{"record":{"id":"495f037da0c8cfc6","repo":"apache/beam","slug":"sessions-is-not-allowed-in-side-inputs","errorCode":null,"errorMessage":"Sessions is not allowed in side inputs","messagePattern":"Sessions is not allowed in side inputs","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/Sessions.java","lineNumber":97,"sourceCode":"  @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() {\n    return gapDuration;\n  }\n\n  @Override\n  public void populateDisplayData(DisplayData.Builder builder) {\n    super.populateDisplayData(builder);\n    builder.add(DisplayData.item(\"gapDuration\", gapDuration).withLabel(\"Session Gap Duration\"));\n  }\n\n  @Override\n  public boolean equals(@Nullable Object object) {\n    if (!(object instanceof Sessions)) {\n      return false;\n    }\n    Sessions other = (Sessions) object;","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/Sessions.java#L79-L115","documentation":"Sessions windows are data-driven (gap duration extends on each element), so there is no static function mapping an arbitrary main window to a Sessions side-input window. Beam therefore refuses to use Sessions as a side input by throwing UnsupportedOperationException in getDefaultWindowMappingFn.","triggerScenarios":"Calling Sessions.getDefaultWindowMappingFn() directly, or using a Sessions-windowed PCollection as a side input (View.asList/asMap) while the main input is in a different window.","commonSituations":"Trying sideInput(view) where the view was built from a Sessions-windowed collection; pipeline validation failures during PTransform expansion when window mapping is needed.","solutions":["Re-window the side input to FixedWindows or GlobalWindows before creating the view","If a global snapshot is acceptable, apply Window.into(new GlobalWindows()) then View.asList()","Restructure the pipeline to join within Sessions windows instead of using side inputs"],"exampleFix":"// before\nPCollectionView<List<T>> view = sessionsPco.apply(Window.into(Sessions.withGapDuration(g))).apply(View.asList());\n// after\nPCollectionView<List<T>> view = sessionsPco.apply(Window.into(new GlobalWindows())).apply(View.asList());","handlingStrategy":"validation","validationCode":"if (sideWindowFn instanceof Sessions) throw new IllegalArgumentException(\"Sessions cannot back a side input; re-window first\");","typeGuard":"boolean usableAsSideInput(WindowFn<?,?> fn) { try { fn.getDefaultWindowMappingFn(); return true; } catch (UnsupportedOperationException e) { return false; } }","tryCatchPattern":null,"preventionTips":["Remember Sessions is data-driven and unsupported for side inputs","Convert Sessions output to GlobalWindows or FixedWindows before View.*","Keep side inputs on fixed/global windowing by convention"],"tags":["java","apache-beam","windowing","side-input","sessions"],"backgroundTag":"unsupported-operation","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"}