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-51040] Enforce determinism when assigning implicit aliases to collation types #49735

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mihailotim-db
Copy link
Contributor

What changes were proposed in this pull request?

This PR proposes a change that enforces determinism when assigning implicit aliases to collation types.

Why are the changes needed?

With the current implementation, Alias can be computed both before and after type coercion rule. This will cause non-deterministic behavior when assigning implicit aliases to objects that are (or will be) type coerced to collation type.

Given a query like:
select concat_ws(' ' collate utf8_lcase, utf8_binary, 'SQL' collate utf8_lcase) from t5
will produce output schema:
concat_ws(collate( , utf8_lcase), utf8_binary, collate(SQL, utf8_lcase))

On the other hand, query like:
select 'a' collate unicode < 'A'
will produce output schema:
(collate(a, unicode) < 'A' collate UNICODE)

This PR will remove collate from alias, making it deterministic in all cases.

Does this PR introduce any user-facing change?

Yes. Output schema will be changed in certain cases, as mentioned above.

How was this patch tested?

Modified existing tests.

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

No

@github-actions github-actions bot added the SQL label Jan 30, 2025
@mihailotim-db mihailotim-db force-pushed the mihailotim-db/fix_collation_alias branch from 7d25a4c to 380f1c8 Compare January 30, 2025 18:33
@mihailotim-db mihailotim-db force-pushed the mihailotim-db/fix_collation_alias branch from 380f1c8 to c262fbe Compare January 30, 2025 20:31
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.

1 participant