Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a varint32 coder and used it for RowCoder #34354

Merged
merged 3 commits into from
Mar 24, 2025

Conversation

Abacn
Copy link
Contributor

@Abacn Abacn commented Mar 20, 2025

Fix #34089

This fixes negative int32 field passed from java to python in xlang transform

Please add a meaningful description for your change here


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@Abacn
Copy link
Contributor Author

Abacn commented Mar 20, 2025

Python3.9 test passed but 3.2 test failed, due to

E           FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.apache_beam/cache/jars/mysql-connector-java-8.0.28.jar.tmp' -> '/home/runner/.apache_beam/cache/jars/mysql-connector-java-8.0.28.jar'

Likely a race condition that two rename run at the same time when tests run in parallel:

os.rename(cached_jar + '.tmp', cached_jar)

@liferoad liferoad mentioned this pull request Mar 20, 2025
3 tasks
@Abacn Abacn marked this pull request as ready for review March 20, 2025 17:28
@Abacn
Copy link
Contributor Author

Abacn commented Mar 20, 2025

R: @liferoad

Copy link
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@Abacn
Copy link
Contributor Author

Abacn commented Mar 21, 2025

R: @kennknowles also

@@ -650,6 +650,25 @@ def __hash__(self):
Coder.register_structured_urn(common_urns.coders.VARINT.urn, VarIntCoder)


class VarInt32Coder(FastCoder):
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add this to CHANGES.md?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, will do as a follow up (otherwise need to rebase this PR onto latest master to be able to add to 2.65.0 section)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opened #34408

@Abacn Abacn merged commit 5f583ea into apache:master Mar 24, 2025
91 checks passed
@Abacn Abacn deleted the varint32coder branch March 24, 2025 19:53
@Abacn
Copy link
Contributor Author

Abacn commented Mar 26, 2025

This appears to break

test_avro_schema_to_beam_schema_with_nullable_atomic_fields (apache_beam.io.avroio_test.TestFastAvro)

E File "apache_beam/coders/coder_impl.py", line 983, in apache_beam.coders.coder_impl.VarInt32CoderImpl.encode_to_stream
E OverflowError: value too large to convert to int32_t [while running 'Map()-ptransform-56']

@Amar3tto
Copy link
Collaborator

This appears to break

test_avro_schema_to_beam_schema_with_nullable_atomic_fields (apache_beam.io.avroio_test.TestFastAvro)

E File "apache_beam/coders/coder_impl.py", line 983, in apache_beam.coders.coder_impl.VarInt32CoderImpl.encode_to_stream E OverflowError: value too large to convert to int32_t [while running 'Map()-ptransform-56']

Also breaks these XVR jobs: #31418, #30601, #30602, #30593, #30517

@Abacn
Copy link
Contributor Author

Abacn commented Mar 26, 2025

Yeah they all fails on same test. Let me investigate now.

From first glance it fails on encoding, which means the row passing in already have large integers

@Abacn
Copy link
Contributor Author

Abacn commented Mar 26, 2025

hmmm test passed locally:

apache_beam/io/avroio_test.py::TestFastAvro::test_avro_schema_to_beam_schema_with_nullable_atomic_fields PASSED [100%]

================================================================================ 1 passed in 13.05s ================================================================================

@Abacn
Copy link
Contributor Author

Abacn commented Mar 26, 2025

It turns out that the test already had an integar overflow in Row passed in:

print out the pcollection pass going to pass to SqlTransform:

| beam.Map(avro_dict_to_beam_row(avro_schema, beam_schema))

Row(name='Henry', favorite_number=3, favorite_color='green')
Row(name='Toby', favorite_number=7, favorite_color='brown')
Row(name='Gordon', favorite_number=4, favorite_color='blue')
Row(name='Emily', favorite_number=4294967295, favorite_color='Red')
Row(name='Percy', favorite_number=6, favorite_color='Green')
Row(name='Bruce', favorite_number=None, favorite_color=None)

this happens to both before and after this change (#34354)

more suprisingly, when read back, it converts back to -1:

{'name': 'Thomas', 'favorite_number': 1, 'favorite_color': 'blue'}
{'name': 'Henry', 'favorite_number': 3, 'favorite_color': 'green'}
{'name': 'Toby', 'favorite_number': 7, 'favorite_color': 'brown'}
{'name': 'Gordon', 'favorite_number': 4, 'favorite_color': 'blue'}
{'name': 'Emily', 'favorite_number': -1, 'favorite_color': 'Red'}
{'name': 'Percy', 'favorite_number': 6, 'favorite_color': 'Green'}
{'name': 'Bruce', 'favorite_number': None, 'favorite_color': None}

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]: Cross-language JDBC (MSSQL) - incorrect negative Integer type conversion
4 participants