Skip to content

[YAML] Fix WindowInto day duration parsing and ExtractWindowingInfo duplicate field check (#40902) - #40903

Open
LibenHailu wants to merge 1 commit into
apache:masterfrom
LibenHailu:fix/yaml-windowing-bugs
Open

LibenHailu wants to merge 1 commit into
apache:masterfrom
LibenHailu:fix/yaml-windowing-bugs

Conversation

@LibenHailu

Copy link
Copy Markdown

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:

  • If this contribution is large, please file an Apache Individual Contributor License Agreement.
  • Replace these instructions with a description of your change and why you have made it.
  • Mention the appropriate issue in your description (for example: addresses #123 or fixes #456).
  • Update CHANGES.md with noteworthy changes.

@github-actions github-actions Bot added python yaml size/s S: 10-49 lines changed labels Oct 30, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 Review Summary

This PR cleanly resolves two bugs in Beam YAML windowing transforms: correcting the 'd' (day) duration multiplier in WindowInto._parse_duration from 12 hours (60 * 60 * 12) to 24 hours (60 * 60 * 24), and fixing _ExtractWindowingInfo so that duplicate field validation checks against field names rather than (name, type) tuples. The accompanying unit tests in yaml_transform_test.py and yaml_mapping_test.py thoroughly cover both fixes.

🔍 General Feedback

  • The changes are minimal, well-scoped, and adhere to existing codebase conventions.
  • Unit tests directly verify both the duration parsing helper and end-to-end YAML transform execution.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @chamikaramj for label yaml.
Backup reviewer: derrickaw (if the main reviewer is unresponsive, you can escalate to them by tagging their username)

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [YAML] WindowInto parses 'd' (days) as 12 hours instead of 24 hours, and ExtractWindowingInfo fails to detect duplicate schema fields

1 participant