shaheeramjad opened a new pull request, #37470:
URL: https://github.com/apache/beam/pull/37470
Adds `take(n)` convenience for PCollection: get the first N elements
deterministically without using `Top.Of` + `FlatMap` manually.
## Changes
- **transforms/util.py:** Add `Take` transform and `take(n)` function (uses
Top.Of + FlatMap internally).
- **pvalue.py:** Add `PCollection.take(n)` method.
- **util_test.py:** Add `TakeTest` (function/method syntax, edge cases,
invalid n).
- **CHANGES.md:** New Features entry for take(n).
## Usage
# Function syntax
first_10 = pcoll | beam.take(10)
# Method syntax
first_10 = pcoll.take(10)
Fixes #37429
------------------------
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [x] Mention the appropriate issue in your description (for example:
`addresses #123`), if applicable. This will automatically add a link to the
pull request in the issue. If you would like the issue to automatically close
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [x] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more
tips on [how to make review process
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit
[https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
--
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]