{"record":{"id":"edd6cd121ca9aaf1","repo":"apache/beam","slug":"error-with-side-input-d-in-dofn-v-pcollections-using-merging","errorCode":null,"errorMessage":"error with side input %d in DoFn %v: PCollections using merging WindowFns are not supported as side inputs. Consider re-windowing the side input PCollection before use","messagePattern":"error with side input (.+?) in DoFn (.+?): PCollections using merging WindowFns are not supported as side inputs\\. Consider re-windowing the side input PCollection before use","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/pardo.go","lineNumber":63,"sourceCode":"\tdoFnOpt := graph.NumMainInputs(graph.MainSingle)\n\t// Check the PCollection for any keyed type (not just KV specifically).\n\tif typex.IsKV(col.Type()) {\n\t\tdoFnOpt = graph.NumMainInputs(graph.MainKv)\n\t} else if typex.IsCoGBK(col.Type()) {\n\t\tdoFnOpt = graph.CoGBKMainInput(len(col.Type().Components()))\n\t}\n\tfn, err := graph.NewDoFn(dofn, doFnOpt)\n\tif err != nil {\n\t\treturn nil, addParDoCtx(err, s)\n\t}\n\n\tin := []*graph.Node{col.n}\n\tinWfn := col.n.WindowingStrategy().Fn\n\tfor i, s := range side {\n\t\tsideNode := s.Input.n\n\t\tsideWfn := sideNode.WindowingStrategy().Fn\n\t\tif sideWfn.Kind == window.Sessions {\n\t\t\treturn nil, fmt.Errorf(\"error with side input %d in DoFn %v: PCollections using merging WindowFns are not supported as side inputs. Consider re-windowing the side input PCollection before use\", i, fn)\n\t\t}\n\t\tif (inWfn.Kind == window.GlobalWindows) && (sideWfn.Kind != window.GlobalWindows) {\n\t\t\treturn nil, fmt.Errorf(\"main input is global windowed in DoFn %v but side input %v is not, cannot map windows correctly. Consider re-windowing the side input PCollection before use\", fn, i)\n\t\t}\n\t\tif (sideWfn.Kind == window.GlobalWindows) && !sideNode.Bounded() {\n\t\t\t// TODO(https://github.com/apache/beam/issues/21596): Replace this warning with an error return when proper streaming test functions have been added.\n\t\t\tlog.Warnf(context.Background(), \"side input %v is global windowed in DoFn %v but is unbounded, DoFn will block until end of Global Window. Consider windowing your unbounded side input PCollection before use. This will cause your pipeline to fail in a future release, see https://github.com/apache/beam/issues/21596 for details\", i, fn)\n\t\t}\n\t\tin = append(in, s.Input.n)\n\t}\n\n\tvar rc *coder.Coder\n\t// Sdfs will always encode restrictions as KV<restriction, watermark state | bool(false)>\n\tif fn.IsSplittable() {\n\t\tsdf := (*graph.SplittableDoFn)(fn)\n\t\trestT := typex.New(sdf.RestrictionT())\n\t\t// If no watermark estimator state, use boolean as a placeholder\n\t\tweT := typex.New(reflect.TypeOf(true))","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/pardo.go#L45-L81","documentation":"During pipeline construction, TryParDo validates side inputs. Beam Go does not support side inputs whose PCollection uses a merging WindowFn (e.g. Sessions), because windows would need to be materialized differently. When a side input's windowing strategy kind is window.Sessions, graph construction fails immediately with this error.","triggerScenarios":"Applying beam.ParDo (or any ParDo variant) with beam.SideInput where the side input PCollection was created with window.Sessions() (window.FixedWindows is fine). Fails at graph build time, before any data flows.","commonSituations":"Enriching a main collection with sessionized aggregates (e.g. joining per-session results as a side input); copying a side-input pattern from code where the side input was re-windowed into sessions for a different consumer.","solutions":["Re-window the side input PCollection into non-merging windows (window.FixedWindows or GlobalWindows) before using it as a side input, as the message suggests.","Convert session results to GlobalWindows with a triggering/accumulation strategy if you need all session data per element.","Restructure as a CoGBK / join instead of a side input if merging-window semantics are essential.","Check for a shared helper that applies window.Sessions() and give the side-input branch its own windowing."],"exampleFix":"// before\nsessions := s | beam.WindowInto(window.NewSessions(10 * time.Minute))\nout := main | beam.ParDo(dofn, beam.SideInput{Input: sessions}) // error\n\n// after\nfixed := s | beam.WindowInto(window.NewFixedWindows(10 * time.Minute))\nout := main | beam.ParDo(dofn, beam.SideInput{Input: fixed})","handlingStrategy":"validation","validationCode":"// Validate side inputs before building the DoFn:\nfunc sideInputIsMerging(w window.Fn) bool {\n    return w.Kind() == window.Sessions\n}\nif sideInputIsMerging(sessionsWfn) {\n    sideInput = sideInput | beam.WindowInto(window.NewFixedWindows(10*time.Minute))\n}","typeGuard":"func nonMergingSideInput(n *graph.Node) bool {\n    return n.WindowingStrategy().Fn.Kind != window.Sessions\n}","tryCatchPattern":null,"preventionTips":["Never use window.Sessions() outputs as side inputs; re-window to fixed/global first.","Centralize windowing helpers so side-input branches get explicit non-merging windows.","Prefer joins/CoGBK when merging-window semantics are truly needed."],"tags":["beam-go","side-input","windowing","graph-validation"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}