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

Add warning about using Schema.FieldType.BYTES keys in a Map #31600

Merged
merged 1 commit into from
Jun 14, 2024

Conversation

Amar3tto
Copy link
Contributor

Resolves #26695


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.

@github-actions github-actions bot added the java label Jun 14, 2024
@Amar3tto Amar3tto force-pushed the bytes-keys-in-map branch from d4c9e31 to 478e7bc Compare June 14, 2024 06:20
@Amar3tto
Copy link
Contributor Author

Run Java PreCommit

@Amar3tto Amar3tto marked this pull request as ready for review June 14, 2024 08:04
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@Amar3tto
Copy link
Contributor Author

R: @Abacn

Copy link
Contributor

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

@@ -816,6 +821,13 @@ public static FieldType iterable(FieldType elementType) {

/** Create a map type for the given key and value types. */
public static FieldType map(FieldType keyType, FieldType valueType) {
if (FieldType.BYTES.equals(keyType)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a valid warning, however may cause log spam as the code path is visited on every value.

A Possible solution is to have a private static flag to track if the warning has been emitted so emit this error once.

Copy link
Contributor Author

@Amar3tto Amar3tto Jun 14, 2024

Choose a reason for hiding this comment

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

I am not sure that it will cause spam, just one message per one creating of FieldType with byte array key in a map.
It's not clear where to have this flag, because FieldType object may exist independently of Schema, in such case we want to have a warning too. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah you are right, here is create FieldType instead of FieldValue

@Abacn Abacn merged commit c02a5e6 into apache:master Jun 14, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: [Java] Row equality not working as expected when ByteBuffer used as Map key
2 participants