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-50579][SQL] Fix truncatedString #49187

Closed
wants to merge 7 commits into from

Conversation

MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented Dec 14, 2024

What changes were proposed in this pull request?

In the PR, I propose to respect the maxFields argument of SparkStringUtils.truncatedString in all cases independently from the size of the another argument seq. If size of seq is grater or equal to maxFields, output exact maxFields elements of seq.

Also, if the number of printed elements is zero, don't print the redundant comma , like [, ... 100 more fields], and don't overflow when maxFields is Int.MinValue.

Why are the changes needed?

To make output consistent for the same maxFields. For example, if maxFields is 2:

truncatedString(Seq(1, 2), "[", ", ", "]", maxFields = 2) -> "[1, 2]"

but for more elements in the input sequence, it prints only one element:

truncatedString(Seq(1, 2, 3), "[", ", ", "]", maxFields = 2) -> "[1, ... 2 more fields]"

though the expected output is "[1, 2, ... 1 more fields]".

Does this PR introduce any user-facing change?

No.

How was this patch tested?

By existing tests from UtilSuite that are moved to StringUtilsSuite and additional checks:

$ build/sbt "test:testOnly *StringUtilsSuite"

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

No.

@github-actions github-actions bot added the SQL label Dec 14, 2024
@MaxGekk MaxGekk changed the title [WIP][SQL] Fix truncatedString [WIP][SPARK-50579][SQL] Fix truncatedString Dec 14, 2024
@MaxGekk MaxGekk changed the title [WIP][SPARK-50579][SQL] Fix truncatedString [SPARK-50579][SQL] Fix truncatedString Dec 14, 2024
@MaxGekk MaxGekk marked this pull request as ready for review December 14, 2024 20:08
@HyukjinKwon
Copy link
Member

Merged to master.

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.

2 participants