junaiddshaukat opened a new issue, #37407:
URL: https://github.com/apache/beam/issues/37407
### What would you like to happen?
## Summary
Add a `filter()` method to the `PCollection` class in the TypeScript SDK,
consistent with the existing `map()` and `flatMap()` methods.
## Motivation
The TypeScript SDK currently provides `map()` and `flatMap()` methods on
`PCollection`, but lacks a `filter()` method. This is explicitly mentioned as a
TODO in the README-dev.md:
> "Also add a [do]Filter, and possibly a [do]Reduce?"
The Python SDK already provides `beam.Filter()` for this purpose. Adding
`filter()` to the TypeScript SDK would:
1. **Improve developer experience** - JavaScript developers expect
`filter()` alongside `map()`
2. **Improve code readability** - `pcoll.filter(x => x > 0)` is cleaner than
`pcoll.flatMap(x => x > 0 ? [x] : [])`
3. **Maintain consistency** with the Python SDK which has `beam.Filter()`
## Proposed API
// Filter even numbers
const evens = pcoll.filter(x => x % 2 === 0);
// Filter with context (for side inputs, etc.)
const filtered = pcoll.filter((x, ctx) => x > ctx.threshold, { threshold:
sideInput });
### Issue Priority
Priority: 2 (default / most feature requests should be filed as P2)
### Issue Components
- [ ] Component: Python SDK
- [ ] Component: Java SDK
- [ ] Component: Go SDK
- [x] Component: Typescript SDK
- [ ] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Samza Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner
--
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]