{"record":{"id":"6c53a003ac7e01fe","repo":"apache/beam","slug":"only-s-objects-with-the-same-number-of-months-day-of-month","errorCode":null,"errorMessage":"Only %s objects with the same number of months, day of month, start date and time zone are compatible.","messagePattern":"Only (.+?) objects with the same number of months, day of month, start date and time zone are compatible\\.","errorType":"exception","errorClass":"IncompatibleWindowException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/CalendarWindows.java","lineNumber":256,"sourceCode":"      return IntervalWindow.getCoder();\n    }\n\n    @Override\n    public boolean isCompatible(WindowFn<?, ?> other) {\n      if (!(other instanceof MonthsWindows)) {\n        return false;\n      }\n      MonthsWindows that = (MonthsWindows) other;\n      return number == that.number\n          && dayOfMonth == that.dayOfMonth\n          && Objects.equals(startDate, that.startDate)\n          && Objects.equals(timeZone, that.timeZone);\n    }\n\n    @Override\n    public void verifyCompatibility(WindowFn<?, ?> other) throws IncompatibleWindowException {\n      if (!this.isCompatible(other)) {\n        throw new IncompatibleWindowException(\n            other,\n            String.format(\n                \"Only %s objects with the same number of months, \"\n                    + \"day of month, start date and time zone are compatible.\",\n                MonthsWindows.class.getSimpleName()));\n      }\n    }\n\n    @Override\n    public void populateDisplayData(DisplayData.Builder builder) {\n      super.populateDisplayData(builder);\n\n      builder\n          .add(DisplayData.item(\"numMonths\", number).withLabel(\"Window Months\"))\n          .addIfNotDefault(\n              DisplayData.item(\"startDate\", new DateTime(startDate, timeZone).toInstant())\n                  .withLabel(\"Window Start Date\"),\n              new DateTime(DEFAULT_START_DATE, DateTimeZone.UTC).toInstant());","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/CalendarWindows.java#L238-L274","documentation":"CalendarWindows.MonthsWindows.verifyCompatibility throws IncompatibleWindowException when a PCollection windowed with MonthsWindows is merged with one using MonthsWindows that differ in number of months, day of month, startDate, or time zone. Beam requires identical calendar alignment for cross-source windowed grouping.","triggerScenarios":"CoGroupByKey/Join/Flatten between two PCollections whose Window.into(...) calls used CalendarWindows.months(n, ...) with differing months(), days (dayOfMonth), startDate, or timeZone.","commonSituations":"Monthly aggregation streams built with different month sizes (1 vs 3 months), different anchor day-of-month, or different time zones combined in one pipeline.","solutions":["Ensure both PCollections use the identical MonthsWindows configuration before merging.","Centralize the windowing definition in shared code/config.","Re-window one side to match the other (assign to the target windows explicitly) before the join.","Use GlobalWindows for the merge if per-calendar-window alignment is not actually required."],"exampleFix":"// before\nPCollection<A> a = inA.apply(Window.into(CalendarWindows.months(1, 15, START, ZONE)));\nPCollection<B> b = inB.apply(Window.into(CalendarWindows.months(1, 1, START, ZONE)));\n// after\nCalendarWindows.MonthsWindows win = CalendarWindows.months(1, 15, START, ZONE);\nPCollection<A> a = inA.apply(Window.into(win));\nPCollection<B> b = inB.apply(Window.into(win));","handlingStrategy":"validation","validationCode":"MonthsWindows a = CalendarWindows.months(n, dayOfMonth, START, ZONE);\nMonthsWindows b = (MonthsWindows) other;\nboolean compatible = a.getMonths() == b.getMonths()\n    && a.getDayOfMonth() == b.getDayOfMonth()\n    && a.getStartDate().equals(b.getStartDate())\n    && a.getTimeZone().equals(b.getTimeZone());","typeGuard":null,"tryCatchPattern":"try {\n  windowFn1.verifyCompatibility(windowFn2);\n} catch (IncompatibleWindowException e) {\n  throw new IllegalStateException(\"MonthsWindows differ (months/dayOfMonth/startDate/zone)\", e);\n}","preventionTips":["Centralize MonthsWindows construction in one factory.","Pin dayOfMonth and timeZone in config for all monthly streams.","Run verifyCompatibility checks in pipeline-construction tests.","Re-window inputs explicitly before merging if configs can diverge."],"tags":["java","apache-beam","windowing","incompatibility"],"backgroundTag":"incompatible-source-type","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"}