jayyyyqwq opened a new pull request, #41950: URL: https://github.com/apache/beam/pull/41950
Addresses #39630 (the merging windows half; custom WindowFns are not covered here). Session windows in the Kafka Streams runner merge into the right window but lose elements. With a 10 ms gap, elements at 1 ms and 4 ms of one key come out as one session `[1ms, 14ms)` that contains only the second one. This is why `GroupByKeyTest$WindowTests.testGroupByKeyMergingWindows` and `CombineTest$WindowingTests.testSessionsCombine` fail on this runner. The cause is in `KafkaStreamsStateInternals`. Every `state()` call binds a new state object, and the state classes don't override `equals`. `StateMerging.mergeBags` uses `source.equals(result)` to skip the cell it is merging into, so that cell is treated as one of the sources: its elements are appended to itself and then `source.clear()` empties it. I added `equals` and `hashCode` on the shared `AbstractState`, comparing the key, the namespace and the state id. Flink's state classes in `FlinkStateInternals` define equality the same way, on namespace and state id. I removed the two tests above from the sickbay list, added `SessionWindowGroupByKeyTest`, and updated the javadoc, the runner documentation page and `CHANGES.md`. Testing, on Windows with JDK 21: - `SessionWindowGroupByKeyTest` fails without the change (key `a` comes out as `[3]` where `[1, 2, 3]` is expected) and passes with it. - `:runners:kafka-streams:validatesRunner`: 61 tests pass, including the two re-enabled ones. On Windows I had to escape the quotes in `beamTestPipelineOptions` with a local init script, which is not part of this PR. - `:runners:kafka-streams:test`: 120 tests pass. `checkstyleMain`, `checkstyleTest`, `javadoc` and `spotbugsMain` pass. - I did not run the broker integration tests or the Python `kafkaStreamsValidatesRunner` suite, which need a Kafka broker. The session skips in `kafka_streams_runner_test.py` (`test_windowing`, `test_windowed_combine_per_key`) are still there. I can look at them in a follow-up. @junaiddshaukat I asked on the issue which parts you plan to pick up. This turned out to be contained, so I'm sending it. Tell me if it overlaps with something you have in progress. @je-ik -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
