LibenHailu opened a new pull request, #40903:
URL: https://github.com/apache/beam/pull/40903
Fixes #40902
### Description
This PR fixes two bugs in Beam YAML windowing transforms:
1. **`YamlProviders.WindowInto._parse_duration` (`yaml_provider.py`)**:
- Fixed the `'d'` (day) time unit multiplier from `60 * 60 * 12` (43,200s
/ 12 hours) to `60 * 60 * 24` (86,400s / 24 hours).
2. **`_ExtractWindowingInfo` (`yaml_mapping.py`)**:
- `named_fields_from_element_type(pcoll.element_type)` returns
`list[tuple[str, type]]`, so `elif field in existing_fields:` was comparing a
`str` against `(str, type)` tuples and always evaluated to `False`.
- Extracted `existing_field_names = {name for name, _ in
existing_fields}` and checked `elif field in existing_field_names:` so that
colliding windowing field names properly raise `ValueError(f'Input schema
already has a field named {field}.')`.
### Tests Added
- `YamlWindowingTest.test_parse_duration` and
`YamlWindowingTest.test_windowing_days` in
`sdks/python/apache_beam/yaml/yaml_transform_test.py`
- `YamlMappingTest.test_extract_windowing_info_duplicate_field` in
`sdks/python/apache_beam/yaml/yaml_mapping_test.py`
------------------------
Thank you for your contribution! Follow this checklist to help us
incorporate your contribution quickly and easily:
- [x] If this contribution is large, please file an Apache [Individual
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
- [x] Replace these instructions with a description of your change and why
you have made it.
- [x] Mention the appropriate issue in your description (for example:
`addresses #123` or `fixes #456`).
- [x] Update `CHANGES.md` with noteworthy changes.
--
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]