{"record":{"id":"878aa88251a69dc2","repo":"apache/beam","slug":"attempted-to-get-side-input-window-for-globalwindow-from-non","errorCode":null,"errorMessage":"Attempted to get side input window for GlobalWindow from non-global WindowFn","messagePattern":"Attempted to get side input window for GlobalWindow from non-global WindowFn","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/PartitioningWindowFn.java","lineNumber":47,"sourceCode":" * @param <W> window type\n */\npublic abstract class PartitioningWindowFn<T, W extends BoundedWindow>\n    extends NonMergingWindowFn<T, W> {\n  /** Returns the single window to which elements with this timestamp belong. */\n  public abstract W assignWindow(Instant timestamp);\n\n  @Override\n  public final Collection<W> assignWindows(AssignContext c) {\n    return Arrays.asList(assignWindow(c.timestamp()));\n  }\n\n  @Override\n  public WindowMappingFn<W> getDefaultWindowMappingFn() {\n    return new WindowMappingFn<W>() {\n      @Override\n      public W getSideInputWindow(BoundedWindow mainWindow) {\n        if (mainWindow instanceof GlobalWindow) {\n          throw new IllegalArgumentException(\n              \"Attempted to get side input window for GlobalWindow from non-global WindowFn\");\n        }\n        return assignWindow(mainWindow.maxTimestamp());\n      }\n    };\n  }\n\n  @Override\n  public final boolean assignsToOneWindow() {\n    return true;\n  }\n}\n","sourceCodeStart":29,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/PartitioningWindowFn.java#L29-L60","documentation":"PartitioningWindowFn assigns windows by partitioning time, so it has no meaningful mapping for GlobalWindow, which has no time domain. When a side input is requested with a main-input GlobalWindow but the side input uses a PartitioningWindowFn, getDefaultWindowMappingFn.getSideInputWindow throws IllegalArgumentException because the mapping is undefined.","triggerScenarios":"Calling getSideInputWindow(GlobalWindow.INSTANCE) on a WindowMappingFn returned by PartitioningWindowFn.getDefaultWindowMappingFn — typically when a global-window PCollection reads a side input windowed by a non-global WindowFn.","commonSituations":"Mixing windowed and unwindowed PCollections: a bounded (global window) main input doing View.asMap side-input lookups against a windowed side input; pipeline graph validation errors during translation.","solutions":["Window the main input with the same (compatible) WindowFn as the side input","Use GlobalWindows for the side input if the main input is in the GlobalWindow","Explicitly set a trigger/windowing on both sides so window mappings align","Re-read the side input via a DoFn that materializes it without window mapping"],"exampleFix":"// before\nPCollectionView<...> view = side.apply(Window.into(new PartitioningWindowFn<>()));\nmain.apply(ParDo.of(new DoFn<Object,Object>(){\n  @ProcessElement public void p(ProcessContext c){ c.sideInput(view); } // throws for GlobalWindow\n}));\n// after\nPCollectionView<...> view = side.apply(Window.into(new GlobalWindows()));","handlingStrategy":"validation","validationCode":"if (mainWindow instanceof GlobalWindow && !(sideWindowFn instanceof GlobalWindows)) {\n  throw new IllegalArgumentException(\"GlobalWindow main input cannot map side input from \" + sideWindowFn.getClass().getSimpleName());\n}","typeGuard":"boolean canMapSideInput(BoundedWindow w, WindowFn<?,?> fn) { return !(w instanceof GlobalWindow) || fn instanceof GlobalWindows; }","tryCatchPattern":null,"preventionTips":["Keep main input and side input windowing aligned by construction","Assert windowing compatibility in pipeline-builder helper methods","Avoid mixing unwindowed and windowed PCollections in one DoFn","Document side-input windowing requirements on shared view factories"],"tags":["java","apache-beam","windowing","side-input"],"backgroundTag":"invalid-argument-value","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"}