Skip to content

Fix beam.Row.__eq__ for rows with trailing columns#23876

Merged
damccorm merged 2 commits intoapache:masterfrom
aliftadvantage:fix-beam-row-eq
Feb 16, 2023
Merged

Fix beam.Row.__eq__ for rows with trailing columns#23876
damccorm merged 2 commits intoapache:masterfrom
aliftadvantage:fix-beam-row-eq

Conversation

@aliftadvantage
Copy link
Copy Markdown
Contributor

@aliftadvantage aliftadvantage commented Oct 27, 2022

The beam.Row.__eq__ operator had unexpected behavior when the rows had a different number of columns.

Specifically the case:

beam.Row(x=1, y=2) == beam.Row(x=1, y=2, z=3) returns true.

This is because zip() drops the trailing columns from the row that has more columns. When all rows are equal trailing rows are ignored and a __eq__ call returns true.

Fix was to replace zip with comparison of the lists of dict items.

cc @robertwb

@aliftadvantage
Copy link
Copy Markdown
Contributor Author

Fixes #23875

@github-actions
Copy link
Copy Markdown
Contributor

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

R: @tvalentyn for label python.

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).

@github-actions
Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

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.

I think we'd like to check the order in which elements were added to the dictionary as per #14156 . Is that the case, @TheNeuralBit ?

If so, we could instead add another condition to make sure dicts has equal # of elements.
Would be nice to add a unit test for this case as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think items will take order into account. But it would be good to have a simple unit test that verifies beam.Row(x=1, y=2) != beam.Row(y=2. x=1).

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.

I added a test test and went ahead with my suggestion. relying on items() alone was not sufficient.

@tvalentyn
Copy link
Copy Markdown
Contributor

PTAL at the formatting / lint failures. you can click on Details -> Console output to see the errors. see also s.apache.org/beam-python-dev-wiki for tips on autoformatting.

@kennknowles
Copy link
Copy Markdown
Member

Do you need more help here? This seems like a potentially important fix.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2023

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@beam.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Feb 6, 2023
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 6, 2023

Codecov Report

Merging #23876 (3be1c5d) into master (299be58) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #23876      +/-   ##
==========================================
- Coverage   72.89%   72.89%   -0.01%     
==========================================
  Files         746      746              
  Lines       99270    99270              
==========================================
- Hits        72365    72362       -3     
- Misses      25542    25545       +3     
  Partials     1363     1363              
Flag Coverage Δ
python 82.17% <100.00%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
sdks/python/apache_beam/pvalue.py 91.44% <100.00%> (ø)
.../python/apache_beam/testing/test_stream_service.py 88.09% <0.00%> (-4.77%) ⬇️
sdks/python/apache_beam/utils/interactive_utils.py 95.12% <0.00%> (-2.44%) ⬇️
.../python/apache_beam/transforms/periodicsequence.py 97.01% <0.00%> (-1.50%) ⬇️
...che_beam/runners/interactive/interactive_runner.py 90.50% <0.00%> (-1.27%) ⬇️
...hon/apache_beam/runners/worker/bundle_processor.py 93.49% <0.00%> (-0.25%) ⬇️
...on/apache_beam/runners/dataflow/dataflow_runner.py 81.88% <0.00%> (+0.14%) ⬆️
...ks/python/apache_beam/runners/worker/sdk_worker.py 89.24% <0.00%> (+0.16%) ⬆️
sdks/python/apache_beam/internal/metrics/metric.py 94.00% <0.00%> (+1.00%) ⬆️
...python/apache_beam/runners/worker/worker_status.py 76.66% <0.00%> (+1.33%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions github-actions bot removed the stale label Feb 7, 2023
@kennknowles
Copy link
Copy Markdown
Member

Would be great to finish this up. If @aliftadvantage does not have time any more, maybe one of the reviewers could make the remaining changes? Is it close?

@tvalentyn
Copy link
Copy Markdown
Contributor

Run Python_PVR_Flink PreCommit

1 similar comment
@tvalentyn
Copy link
Copy Markdown
Contributor

Run Python_PVR_Flink PreCommit

@tvalentyn
Copy link
Copy Markdown
Contributor

R: @damccorm

Copy link
Copy Markdown
Contributor

@damccorm damccorm left a comment

Choose a reason for hiding this comment

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

LGTM

@damccorm damccorm merged commit fce8b65 into apache:master Feb 16, 2023
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.

5 participants