{"record":{"id":"41a4db4047b9c960","repo":"apache/beam","slug":"mismatched-flatten-window-types-v-want-v","errorCode":null,"errorMessage":"mismatched Flatten window types: %v, want %v","messagePattern":"mismatched Flatten window types: (.+?), want (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/edge.go","lineNumber":278,"sourceCode":"\t}\n\tt := in[0].Type()\n\tw := inputWindow(in)\n\n\t// TODO(herohde) 4/5/2018: is it fine mixing boundedness for flatten?\n\t// The output would be unbounded iff any input is.\n\tbounded := true\n\tfor _, n := range in {\n\t\tif !n.Bounded() {\n\t\t\tbounded = false\n\t\t\tbreak\n\t\t}\n\t}\n\tfor _, n := range in {\n\t\tif !typex.IsEqual(t, n.Type()) {\n\t\t\treturn nil, addContext(errors.Errorf(\"mismatched Flatten input types: %v, want %v\", n.Type(), t), s)\n\t\t}\n\t\tif !w.Equals(n.WindowingStrategy()) {\n\t\t\treturn nil, addContext(errors.Errorf(\"mismatched Flatten window types: %v, want %v\", n.WindowingStrategy(), w), s)\n\t\t}\n\t}\n\tif typex.IsCoGBK(t) {\n\t\treturn nil, addContext(errors.Errorf(\"Flatten input type cannot be CoGBK: %v\", t), s)\n\t}\n\n\tedge := g.NewEdge(s)\n\tedge.Op = Flatten\n\tfor _, n := range in {\n\t\tedge.Input = append(edge.Input, &Inbound{Kind: Main, From: n, Type: t})\n\t}\n\tedge.Output = []*Outbound{{To: g.NewNode(t, w, bounded), Type: t}}\n\treturn edge, nil\n}\n\n// NewCrossLanguage inserts a Cross-langugae External transform using initialized input and output nodes\nfunc NewCrossLanguage(g *Graph, s *Scope, ext *ExternalTransform, ins []*Inbound, outs []*Outbound) (*MultiEdge, func(*Node, bool)) {\n\tedge := g.NewEdge(s)","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/edge.go#L260-L296","documentation":"NewFlatten verifies that all inputs use the same WindowingStrategy (compared with `w.Equals(n.WindowingStrategy())`, where w is derived from inputWindow(in)). If any input's windowing differs from the first input's, graph construction fails. Flatten requires homogeneous windowing because the merged output must carry a single strategy.","triggerScenarios":"Flattening PCollections where one has beam.WindowInto applied (fixed/sliding/session/global windows) and another keeps the default global window, or one has custom triggers/allowed lateness.","commonSituations":"Streaming pipelines where one branch is windowed for time-based aggregation and another is not; merging a re-windowed PCollection with the original; differing trigger configurations after GroupByKeys.","solutions":["Apply the same beam.WindowInto to every input PCollection before flattening.","Normalize trigger/lateness settings so all inputs' WindowingStrategies compare equal.","Re-window all branches to a common windowing (e.g., GlobalWindows) before Flatten.","Review which branch mutated windowing (window transforms, custom triggers) and align it."],"exampleFix":"// before\nmerged := beam.Flatten(s, windowedPC, globalPC) // window strategy mismatch\n// after\nreWin := beam.WindowInto(s, window.NewFixedWindows(time.Hour), globalPC)\nmerged := beam.Flatten(s, windowedPC, reWin)","handlingStrategy":"validation","validationCode":"// Go: apply identical windowing to all inputs before Flatten\nwinAll := func(pc beam.PCollection) beam.PCollection {\n    return beam.WindowInto(s, window.NewFixedWindows(time.Hour), pc)\n}\nmerged := beam.Flatten(s, winAll(a), winAll(b))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Window every branch with the same strategy, trigger, and allowed lateness before merging.","Avoid windowing only one branch of a Flatten fan-in.","In streaming pipelines, re-window to a common strategy before any Flatten."],"tags":["beam-go","flatten","windowing","graph-construction"],"backgroundTag":"type-mismatch","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"}