Pratik1326 opened a new pull request, #41884: URL: https://github.com/apache/beam/pull/41884
Fixes #36775 where `PerKey` transforms in `combiners` and `stats` lost concrete element types (falling back to `Any` or partial tuple types) when applied to typed `PCollection`s. ### Summary of Changes - **`Latest.PerKey` & `Latest.Globally` (`sdks/python/apache_beam/transforms/combiners.py`):** Added input type hints on inner `ParDo(self.add_timestamp)` transforms (`tuple[K, V]` for `PerKey` and `T` for `Globally`) and used consistent `V` in `Latest.PerKey`'s inner output tuple type so `Latest.PerKey` preserves concrete key/value element types. - **`ApproximateUnique.PerKey` (`sdks/python/apache_beam/transforms/stats.py`):** Added `@typehints.with_input_types(Any)` and `@typehints.with_output_types(int)` on `ApproximateUniqueCombineFn`. - **`ApproximateQuantiles.PerKey` (`sdks/python/apache_beam/transforms/stats.py`):** Implemented `ApproximateQuantilesCombineFn.default_type_hints()` across standard, weighted, and batched modes so `ApproximateQuantiles.PerKey` infers concrete tuple/list element types. - **Unit Tests (`combiners_test.py`, `stats_test.py`):** Added type-inference and `TypeCheckError` unit tests for `Latest`, `ApproximateUnique.PerKey`, and `ApproximateQuantiles.PerKey`. ### Verification - Verified formatting with `yapf --diff` across modified files. - Ran `pytest` on `combiners_test.py`, `stats_test.py`, `ptransform_test.py`, and `typed_pipeline_test.py` (`432 passed, 6 skipped`). -- 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]
