Skip to content

[SPARK-58689][CORE][TESTS] Add tests for SparkStringUtils padding and abbreviation helpers - #57890

Open
uros-b wants to merge 2 commits into
apache:masterfrom
uros-b:test-sparkstringutils
Open

[SPARK-58689][CORE][TESTS] Add tests for SparkStringUtils padding and abbreviation helpers#57890
uros-b wants to merge 2 commits into
apache:masterfrom
uros-b:test-sparkstringutils

Conversation

@uros-b

@uros-b uros-b commented Aug 10, 2026

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Adds SparkStringUtilsSuite, covering isBlank/isNotBlank, leftPad, both rightPad overloads, both abbreviate overloads, strip, and stringToSeq.

Why are the changes needed?

SparkStringUtils currently has no test suite, while the sibling utilities in the same module (SparkErrorUtilsSuite, SparkFileUtilsSuite, VersionUtilsSuite, ...) each have one. The helpers are not incidental: leftPad/rightPad format the column output of Dataset.show, and abbreviate is used to build Kubernetes application-name labels. The methods arrived across a series of changes that replaced Apache Commons and Guava equivalents, and none of those added direct tests.

The three-argument rightPad(str, width, padStr) holds the most error-prone arithmetic in the file (pad repetition plus truncation of the final repetition) and currently has no caller, so it had no coverage of any kind.

Does this PR introduce any user-facing change?

No. Tests only.

How was this patch tested?

This is the test. Every expected value was derived by executing the current implementations rather than computed by hand, including the pad-truncation cases (rightPad("a", 4, "xy") is "axyx") and the null pass-through paths. The suite was run locally: 6 tests, 27 assertions, all passing.

The suite extends AnyFunSuite with the scalastyle:ignore funsuite marker, matching every sibling suite in this module; common/utils does not depend on spark-core, so SparkFunSuite is not available here.

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

Generated-by: Claude Code (Opus 4.8)

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Waiting for CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant