{"record":{"id":"23baadeef53b2648","repo":"apache/beam","slug":"tried-to-merge-non-interval-window-type-t","errorCode":null,"errorMessage":"tried to merge non-interval window type %T","messagePattern":"tried to merge non-interval window type %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/direct/gbk.go","lineNumber":135,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\tdelete(n.m, key)\n\t}\n\treturn n.Out.FinishBundle(ctx)\n}\n\nfunc (n *CoGBK) mergeWindows() (map[typex.Window]int, error) {\n\tsort.Slice(n.wins, func(i int, j int) bool {\n\t\treturn n.wins[i].MaxTimestamp() < n.wins[j].MaxTimestamp()\n\t})\n\t// mergeMap is a map from the oringal windows to the index of the new window\n\t// in the mergedWins slice\n\tmergeMap := make(map[typex.Window]int)\n\tvar mergedWins []typex.Window\n\tfor i := 0; i < len(n.wins); {\n\t\tintWin, ok := n.wins[i].(window.IntervalWindow)\n\t\tif !ok {\n\t\t\treturn nil, errors.Errorf(\"tried to merge non-interval window type %T\", n.wins[i])\n\t\t}\n\t\tmergeStart := intWin.Start\n\t\tmergeEnd := intWin.End\n\t\tj := i + 1\n\t\tfor j < len(n.wins) {\n\t\t\tcandidateWin := n.wins[j].(window.IntervalWindow)\n\t\t\tif candidateWin.Start <= mergeEnd {\n\t\t\t\tmergeEnd = candidateWin.End\n\t\t\t\tj++\n\t\t\t} else {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tfor k := i; k < j; k++ {\n\t\t\tmergeMap[n.wins[k]] = len(mergedWins)\n\t\t}\n\t\tmergedWins = append(mergedWins, window.IntervalWindow{Start: mergeStart, End: mergeEnd})\n\t\ti = j","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/direct/gbk.go#L117-L153","documentation":"The direct runner's CoGBK transform merges windows by grouping together windows that overlap. Windows in the incoming group are asserted to be `window.IntervalWindow` implementations; if any window is a different type (a custom WindowFn producing non-interval windows), mergeWindows returns this error since the direct runner only supports interval-window merging in this path.","triggerScenarios":"A pipeline using a custom WindowFn (or a built-in one) whose windows do not implement window.IntervalWindow is executed with the direct runner on a CoGBK/group-by-key stage. The error occurs in mergeWindows when type-asserting n.wins[i] to IntervalWindow fails.","commonSituations":"Developers implementing custom windowing functions and running pipelines with the direct runner; switching runners where a windowing scheme supported elsewhere is not supported by the direct GBK merge path.","solutions":["Use a standard interval-based windowing function (window.FixedWindows, window.SlidingWindows, window.Sessions) instead of a custom non-interval WindowFn.","Make the custom WindowFn assign windows that implement the window.IntervalWindow interface (with Start/End methods).","Run the pipeline with a different runner that supports the custom window type."],"exampleFix":"// before: custom non-interval window\ntype GlobalOnlyWindow struct{}\nfunc (GlobalOnlyWindow) AssignWindows(...) { ... }\n// after: interval-based window\nw := window.NewFixedWindows(60 * time.Second)\npcoll := beam.WindowInto(s, w, pcoll)","handlingStrategy":"validation","validationCode":"// Go: assert your windowing assigns IntervalWindows before the GBK stage\nif _, ok := windowing.(interface{ IntervalWindow }) ; !ok { /* switch to FixedWindows/SlidingWindows/Sessions */ }","typeGuard":"func isIntervalWindow(w typex.Window) bool { _, ok := w.(window.IntervalWindow); return ok }","tryCatchPattern":null,"preventionTips":["Prefer built-in interval WindowFns (FixedWindows, SlidingWindows, Sessions) with the direct runner.","When writing custom WindowFns, make assigned windows implement window.IntervalWindow.","Add a unit test exercising GBK under your windowing before running the full pipeline."],"tags":["go","beam","windows","runner"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}