apache/beam · error

combine does not support side inputs

Error message

combine does not support side inputs

What it means

beam.TryCombinePerKey validates its options and rejects any side inputs: the Go Combine transform does not implement side-input consumption. If validate() reports side inputs among opts, it returns this error wrapped with addCombinePerKeyCtx.

Source

Thrown at sdks/go/pkg/beam/combine.go:65

	return DropKey(s, post), nil
}

func addCombinePerKeyCtx(err error, s Scope) error {
	return errors.WithContextf(err, "inserting CombinePerKey in scope %s", s)
}

// TryCombinePerKey attempts to insert a per-key Combine transform into the pipeline. It may fail
// for multiple reasons, notably that the combinefn is not valid or cannot be bound
// -- due to type mismatch, say -- to the incoming PCollection.
func TryCombinePerKey(s Scope, combinefn any, col PCollection, opts ...Option) (PCollection, error) {
	s = s.Scope(graph.CombinePerKeyScope)
	ValidateKVType(col)
	side, typedefs, err := validate(s, col, opts)
	if err != nil {
		return PCollection{}, addCombinePerKeyCtx(err, s)
	}
	if len(side) > 0 {
		return PCollection{}, addCombinePerKeyCtx(errors.New("combine does not support side inputs"), s)
	}

	col, err = TryGroupByKey(s, col)
	if err != nil {
		return PCollection{}, addCombinePerKeyCtx(err, s)
	}

	fn, err := graph.NewCombineFn(combinefn)
	if err != nil {
		return PCollection{}, addCombinePerKeyCtx(err, s)
	}
	// This seems like the best place to infer the accumulator coder type, unless
	// it's a universal type.
	// We can get the fulltype from the return value of the mergeAccumulatorFn
	// TODO(lostluck): 2018/05/28 Correctly infer universal type coder if necessary.
	accumCoder, err := inferCoder(typex.New(fn.MergeAccumulatorsFn().Ret[0].T))
	if err != nil {
		wrapped := errors.Wrap(err, "unable to infer CombineFn accumulator coder")

View on GitHub (pinned to 12126d8942)

Solutions

  1. Remove the SideInput option; do the combine on the main input only.
  2. Pre-join the side data into the main PCollection (CoGroupByKey or side-input via beam.ParDo) before combining.
  3. Broadcast small side data as a singleton view and read it inside the Fn via an emulated mechanism, or restructure as a GroupByKey + custom ParDo.

Example fix

// before
beam.CombinePerKey(s, fn, beam.SideInput{Input: dims})
// after
beam.CombinePerKey(s, fn) // join dims separately via CoGroupByKey
Defensive patterns

Strategy: validation

Validate before calling

for _, o := range opts {
	if _, ok := o.(beam.SideInput); ok {
		return errors.New("CombinePerKey does not accept SideInput options; pre-join instead")
	}
}

Try / catch

col, err := beam.TryCombinePerKey(s, col, opts...)
if err != nil && strings.Contains(err.Error(), "does not support side inputs") {
	// restructure with CoGroupByKey
}

Prevention

When it happens

Trigger: Calling beam.CombinePerKey/TryCombinePerKey with a SideInput options (beam.SideInput from a side PCollections list), e.g. beam.CombinePerKey(fn, beam.SideInput{Input: otherCol}).

Common situations: Porting a Python/Java combine-with-sides pattern to Go, or copying a combine Fn signature that takes an iter side input.

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/01a4576f66a09d0b. Report an issue: GitHub.