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

[SPARK-48435][SQL] UNICODE collation should not support binary equality #46772

Closed
wants to merge 9 commits into from

Conversation

uros-db
Copy link
Contributor

@uros-db uros-db commented May 28, 2024

What changes were proposed in this pull request?

CollationFactory has been updated to no longer mark UNICODE as collation that supportsBinaryCollation. To reflect these changes, various tests have been updated.

However, some tests have been (temporarily) removed because StringTrim no longer supports UNICODE collation given the new UNICODE definition in CollationFactory. At this time, StringTrim expression only supports UTF8_BINARY & UTF8_BINARY_LCASE, but not ICU collations. This work is in progress (#46762), so we'll ensure appropriate test coverage with those changes.

Why are the changes needed?

UNICODE collation should not support binary collation. Note: in the future, we may want to consider a collation such as UNICODE_BINARY, which will support binary equality, but also maintain UNICODE ordering.

Does this PR introduce any user-facing change?

Yes, UNICODE is no longer treated as a binary collation. This affects how equality works for UNICODE, and also which codepath is taken for various collation-aware string expression given UNICODE collated string arguments.

How was this patch tested?

Updated existing unit and e2e sql test for UNICODE collation.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label May 28, 2024
@@ -245,12 +245,12 @@ public CollationIdentifier identifier() {
PROVIDER_ICU,
Collator.getInstance(ULocale.ROOT),
"153.120.0.0",
true,
false,
Copy link
Contributor Author

@uros-db uros-db May 28, 2024

Choose a reason for hiding this comment

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

note for reviewers: this is the place we say UNICODE does not supportBinaryEquality

@uros-db
Copy link
Contributor Author

uros-db commented May 28, 2024

another note for future reference: as per ICU docs, we've decided to stick with TERTIARY collation strength for UNICODE

Copy link
Contributor

@mkaravel mkaravel left a comment

Choose a reason for hiding this comment

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

The changes regarding the definition of the UNICODE collation look good.
I would like to understand why we are removing test cases and/or changing test cases from UNICODE to UTF8_BINARY. Aren't we los coverage with this PR?

@uros-db
Copy link
Contributor Author

uros-db commented May 29, 2024

As noted in one of the resolved comments - there's no loss of coverage. However, some tests have been (temporarily) removed because StringTrim no longer supports UNICODE collation given the new UNICODE definition in CollationFactory

At this time, StringTrim expression only supports UTF8_BINARY & UTF8_BINARY_LCASE, but not ICU collations. This work is in progress, so we'll make sure to have appropriate test coverage at that point!

@uros-db uros-db requested a review from mkaravel May 31, 2024 12:20
Copy link
Contributor

@mkaravel mkaravel left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this!
LGTM.

@mkaravel
Copy link
Contributor

mkaravel commented Jun 6, 2024

As noted in one of the resolved comments - there's no loss of coverage. However, some tests have been (temporarily) removed because StringTrim no longer supports UNICODE collation given the new UNICODE definition in CollationFactory

At this time, StringTrim expression only supports UTF8_BINARY & UTF8_BINARY_LCASE, but not ICU collations. This work is in progress, so we'll make sure to have appropriate test coverage at that point!

This explanation would fit very nicely in the PR description (explaining what are the changes in the PR). Your call.

@uros-db uros-db changed the title [WIP][SPARK-48435][SQL] UNICODE collation should not support binary equality [SPARK-48435][SQL] UNICODE collation should not support binary equality Jun 6, 2024
@uros-db
Copy link
Contributor Author

uros-db commented Jun 6, 2024

updated PR title and description
@cloud-fan please review

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in b5a4b32 Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants