{"record":{"id":"71d799ba7fbdabc4","repo":"apache/beam","slug":"only-s-objects-with-the-same-number-of-days-start-date-and","errorCode":null,"errorMessage":"Only %s objects with the same number of days, start date and time zone are compatible.","messagePattern":"Only (.+?) objects with the same number of days, 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":146,"sourceCode":"    public Coder<IntervalWindow> windowCoder() {\n      return IntervalWindow.getCoder();\n    }\n\n    @Override\n    public boolean isCompatible(WindowFn<?, ?> other) {\n      if (!(other instanceof DaysWindows)) {\n        return false;\n      }\n      DaysWindows that = (DaysWindows) other;\n      return number == that.number\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 days, start date \"\n                    + \"and time zone are compatible.\",\n                DaysWindows.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(\"numDays\", number).withLabel(\"Windows Days\"))\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":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/CalendarWindows.java#L128-L164","documentation":"CalendarWindows.DaysWindows.verifyCompatibility throws IncompatibleWindowException when merging/grouping streams whose WindowFn is a DaysWindows with a different number of days, start date, or time zone. Beam requires both sides of a join/GroupByKey across sources to use compatible windowing so windows line up element-wise.","triggerScenarios":"Using CalendarWindows.days(n) (with differing days(), startDate, or timeZone arguments) in a PCollection that is joined, flattened, or grouped with another PCollection using CalendarWindows.days(m) with different parameters.","commonSituations":"Two pipelines/PCollections built by different teams with different calendar window configs (e.g. 7 days vs 14 days, UTC vs local zone, or different startDate), then combined with CoGroupByKey or Flatten.","solutions":["Align the DaysWindows parameters (number of days, startDate, timeZone) on both PCollections before the join/flatten.","Extract the window parameters into shared constants/config so both sides use the same values.","If different calendar windows are intentional, convert one side's windows first (e.g. re-window via a Window.transform and re-assign timestamps) or use GlobalWindows for the merge.","Catch IncompatibleWindowException during pipeline construction to fail fast with a clear configuration check."],"exampleFix":"// before\nPCollection<A> a = inputA.apply(Window.into(CalendarWindows.days(7)));\nPCollection<B> b = inputB.apply(Window.into(CalendarWindows.days(14)));\nPCollection<Pair> joined = KeyedPCollectionTuple.of(t1, a).and(t2, b).apply(CoGroupByKey.create());\n// after\nCalendarWindows.DaysWindows win = CalendarWindows.days(7, START_DATE, ZoneId.of(\"UTC\"));\nPCollection<A> a = inputA.apply(Window.into(win));\nPCollection<B> b = inputB.apply(Window.into(win));","handlingStrategy":"validation","validationCode":"DaysWindows w1 = CalendarWindows.days(7, START, ZONE);\nDaysWindows w2 = (DaysWindows) other;\nboolean compatible = w1.getDays() == w2.getDays()\n    && w1.getStartDate().equals(w2.getStartDate())\n    && w1.getTimeZone().equals(w2.getTimeZone());","typeGuard":null,"tryCatchPattern":"try {\n  windowFn1.verifyCompatibility(windowFn2);\n} catch (IncompatibleWindowException e) {\n  throw new IllegalStateException(\"Align DaysWindows params before merging: \" + e.getMessage(), e);\n}","preventionTips":["Define calendar window parameters once in shared config, not per-pipeline.","Always specify the same timeZone explicitly (never rely on JVM default).","Call verifyCompatibility on both WindowFns during pipeline setup for fail-fast checks.","Before joining calendar-windowed streams, confirm days/startDate/zone match."],"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"}