Thanatos9404 opened a new pull request, #41570: URL: https://github.com/apache/beam/pull/41570
Fixes #41568 With default windowing, `Top.Of` takes a per-bundle path. That path always flattened in an empty accumulator so the output would never be empty, and `_TopPerBundle.finish_bundle` also emitted one for a bundle without elements. So `Top.Of(n).without_defaults()`, `Top.Largest(n, has_defaults=False)` and `Top.Smallest(n, has_defaults=False)` still produced `[]` for an empty input. With other windowing the flag already worked, because that path uses `CombineGlobally(...).without_defaults()`. Now: - the empty accumulator is added only when `has_defaults` is set, so the graph for the default case is unchanged; - `_TopPerBundle` emits nothing for a bundle that had no elements. Tests in `combiners_test.py`: - `test_empty_global_top_without_defaults` checks `Top.Of`, `Top.Largest` and `Top.Smallest` on an empty input, and fails without the change. - `test_global_top_without_defaults` checks that a non-empty input still gives its result. `test_empty_global_top` (with defaults) still gives `[[]]`, and the rest of `combiners_test.py` passes. yapf is clean. I also added a `CHANGES.md` entry under Bugfixes for 2.79.0. -- 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]
