apache/beam · error · IllegalArgumentException

Attempted to get side input window for GlobalWindow from non

Error message

Attempted to get side input window for GlobalWindow from non-global WindowFn

What it means

Like PartitioningWindowFn, SlidingWindows' default side-input mapping cannot map GlobalWindow (which has no timestamp) onto a sliding IntervalWindow, so getSideInputWindow throws IllegalArgumentException when handed a GlobalWindow. The mapping is only defined for time-windowed main inputs.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/SlidingWindows.java:129

    for (long start = lastStart;
        start > timestamp.minus(size).getMillis();
        start -= period.getMillis()) {
      windows.add(new IntervalWindow(new Instant(start), size));
    }
    return windows;
  }

  /**
   * Return a {@link WindowMappingFn} that returns the earliest window that contains the end of the
   * main-input window.
   */
  @Override
  public WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn() {
    return new WindowMappingFn<IntervalWindow>() {
      @Override
      public IntervalWindow getSideInputWindow(BoundedWindow mainWindow) {
        if (mainWindow instanceof GlobalWindow) {
          throw new IllegalArgumentException(
              "Attempted to get side input window for GlobalWindow from non-global WindowFn");
        }
        long lastStart = lastStartFor(mainWindow.maxTimestamp().minus(size));
        return new IntervalWindow(new Instant(lastStart + period.getMillis()), size);
      }
    };
  }

  @Override
  public boolean isCompatible(WindowFn<?, ?> other) {
    return equals(other);
  }

  @Override
  public boolean assignsToOneWindow() {
    return !this.period.isShorterThan(this.size);
  }

View on GitHub (pinned to 12126d8942)

Solutions

  1. Window the main input with SlidingWindows (or a compatible time windowfn) before sideInput
  2. Re-window the side input to GlobalWindows if a global view is intended
  3. Use FixedWindows on the side input with a WindowMappingFn you control
  4. Align both PCollections with the same Window.into() call

Example fix

// before
PCollectionView<X> v = slidingPco.apply(View.asMap());
boundedPco.apply(ParDo.of(new DoFn<T,U>(){ @ProcessElement void p(ProcessContext c){ c.sideInput(v);}}));
// after
PCollectionView<X> v = slidingPco.apply(Window.into(new GlobalWindows())).apply(View.asMap());
Defensive patterns

Strategy: validation

Validate before calling

if (mainWindow instanceof GlobalWindow && sideWindowFn instanceof SlidingWindows) throw new IllegalArgumentException("Re-window side input to GlobalWindows before sideInput");

Type guard

boolean canUseSlidingSideInput(BoundedWindow w, WindowFn<?,?> fn) { return !(w instanceof GlobalWindow) || !(fn instanceof SlidingWindows); }

Prevention

When it happens

Trigger: Requesting a side input whose PCollection uses SlidingWindows while the main element is in the GlobalWindow — i.e. getSideInputWindow(GlobalWindow.INSTANCE) on the SlidingWindows mapping fn.

Common situations: Unwindowed/bounded main PCollection reading a sliding-window side input; combining a batch (global window) source with a streaming sliding-window view in the same DoFn.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/b277688c52c79e1e. Report an issue: GitHub.