Skip to content

[Python/YAML] Accept >=, <=, == and != in generic Filter expressions … - #41044

Merged
derrickaw merged 2 commits into
apache:masterfrom
jk-shah:fix-yaml-generic-cmp
Nov 6, 2026
Merged

derrickaw merged 2 commits into
apache:masterfrom
jk-shah:fix-yaml-generic-cmp

Conversation

@jk-shah

@jk-shah jk-shah commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

…(#41043)

validate_generic_expression split comparisons with a greedy regex, so a two-character operator lost its first character to the left operand ('age >= 21' became 'age >', '=', ' 21') and the expression was rejected. Only < and > worked. Make the left operand non-greedy and add tests for every operator.

Fixes #41043.

…pache#41043)

validate_generic_expression split comparisons with a greedy regex, so a
two-character operator lost its first character to the left operand
('age >= 21' became 'age >', '=', ' 21') and the expression was rejected.
Only < and > worked. Make the left operand non-greedy and add tests for
every operator.

Fixes apache#41043.
@github-actions github-actions Bot added python yaml size/s S: 10-49 lines changed labels Nov 6, 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 fixes a regex greediness bug in validate_generic_expression where two-character comparison operators (>=, <=, ==, !=) were split across the left operand and operator capture groups in Beam YAML generic expressions. The change makes the left operand capture group non-greedy and adds comprehensive unit and pipeline tests covering all supported comparison operators.

🔍 General Feedback

  • The fix in sdks/python/apache_beam/yaml/yaml_mapping.py is minimal, accurate, and cleanly preserves full multi-character operators during validation.
  • Unit tests in ValidateGenericExpressionTest and the end-to-end Filter test in YamlMappingTest thoroughly cover valid operators, whitespace variations, and invalid expressions.

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

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @derrickaw for label yaml.
Backup reviewer: chamikaramj (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).

@derrickaw

Copy link
Copy Markdown
Collaborator

LGTM, lets wait on checks, thanks

@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.95%. Comparing base (625716a) to head (a813c26).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #41044      +/-   ##
============================================
- Coverage     58.96%   58.95%   -0.01%     
  Complexity     4768     4768              
============================================
  Files          1464     1464              
  Lines        185853   185853              
  Branches       3585     3585              
============================================
- Hits         109580   109578       -2     
- Misses        72927    72929       +2     
  Partials       3346     3346              
Flag Coverage Δ
python 80.26% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@derrickaw
derrickaw merged commit 63b69ed into apache:master Nov 6, 2026
87 checks passed
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]: [Python/YAML] Beam YAML generic Filter rejects >=, <=, ==, and != comparisons

2 participants