apache/beam · error · ValueError

Default values are not yet supported in CombineGlobally()…

Error message

Default values are not yet supported in CombineGlobally() if the output  PCollection is not windowed by GlobalWindows. Instead, use CombineGlobally().without_defaults() to output an empty PCollection if the input PCollection is empty, or CombineGlobally().as_singleton_view() to get the default output of the CombineFn if the input PCollection is empty.

What it means

When a CombineGlobally has default values enabled (i.e. neither without_defaults nor as_singleton_view was used) but the input PCollection is not windowed by GlobalWindows, Beam cannot safely provide a default output per window, so it raises this ValueError at pipeline construction time.

Solutions

  1. Call .without_defaults() to get an empty output PCollection when input is empty
  2. Call .as_singleton_view() to obtain the CombineFn's default as a singleton view
  3. Switch the PCollection to GlobalWindows only if that is genuinely correct for the aggregation

Example fix

// before
pcoll | beam.CombineGlobally(sum)
// after
pcoll | beam.CombineGlobally(sum).without_defaults()
Defensive patterns

Strategy: validation

Validate before calling

from apache_beam import window
if pcoll.windowing.windowfn != window.GlobalWindows() and combine_defaults_requested:
    combine = combine.without_defaults()  # or .as_singleton_view()

Type guard

def defaults_safe_for_windowing(pcoll) -> bool:
    return pcoll.windowing.windowfn == pcoll.windowing.windowfn.__class__() and type(pcoll.windowing.windowfn).__name__ == 'GlobalWindows'

Try / catch

try:
    expanded = pcoll | beam.CombineGlobally(fn)
except ValueError as e:
    if 'Default values are not yet supported' in str(e):
        expanded = pcoll | beam.CombineGlobally(fn).without_defaults()
    else:
        raise

Prevention

When it happens

Trigger: Applying beam.CombineGlobally(fn) (with defaults) to a PCollection whose windowing is e.g. FixedWindows/SlidingWindows — i.e. any non-global windowfn — with default_value semantics requested.

Common situations: Stream/windowed pipelines where a developer adds a combine for aggregates and expects an empty-result default; Beam requires explicitly choosing the empty-PCollection or singleton-view behavior instead.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/transforms/core.py:3019

    if not self.has_defaults and not self.as_view:
      return combined

    elif self.as_view:
      if self.has_defaults:
        try:
          combine_fn.setup(*self.args, **self.kwargs)
          # This is called in the main program, but cannot be avoided
          # in the as_view case as it must be available to all windows.
          default_value = combine_fn.apply([], *self.args, **self.kwargs)
        finally:
          combine_fn.teardown(*self.args, **self.kwargs)
      else:
        default_value = pvalue.AsSingleton._NO_DEFAULT
      return pvalue.AsSingleton(combined, default_value=default_value)

    else:
      if pcoll.windowing.windowfn != GlobalWindows():
        raise ValueError(
            "Default values are not yet supported in CombineGlobally() if the "
            "output  PCollection is not windowed by GlobalWindows. "
            "Instead, use CombineGlobally().without_defaults() to output "
            "an empty PCollection if the input PCollection is empty, "
            "or CombineGlobally().as_singleton_view() to get the default "
            "output of the CombineFn if the input PCollection is empty.")

      # log the error for this ill-defined streaming case now
      if not pcoll.is_bounded and not pcoll.windowing.is_default():
        _LOGGER.error(
            "When combining elements in unbounded collections with "
            "the non-default windowing strategy, you must explicitly "
            "specify how to define the combined result of an empty window. "
            "Please use CombineGlobally().without_defaults() to output "
            "an empty PCollection if the input PCollection is empty.")

      def typed(transform):
        # TODO(robertwb): We should infer this.

View on GitHub (pinned to 12126d8942)