Skip to content

[SPARK-52583][SQL] Add an Developer API for stringifying values in UserDefinedType #51289

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

Closed
wants to merge 3 commits into from

Conversation

yaooqinn
Copy link
Member

What changes were proposed in this pull request?

This PR proposes to add a Developer API for stringifying values in UserDefinedType. When casting a Class X instance that UserDefinedType represents in the Catalyst layer, this API will be called to get the string representation. The default implementation of this API is to call obj.toString with the AS-IS behavior.

Why are the changes needed?

The Class X's toString method doesn't always meet the needs of users, and it's difficult for them to override it in some circumstances. For example, it's a JVM implementation or from other dependent projects.

This stringifyValue API gives a user or developer an extra opportunity to do the override.

Does this PR introduce any user-facing change?

No, it's a developer API addition and the behavior remains

How was this patch tested?

New test cases

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

no

@github-actions github-actions bot added the SQL label Jun 26, 2025
@yaooqinn
Copy link
Member Author

cc @cloud-fan @dongjoon-hyun

*/
@Since("4.1.0")
def stringifyValue(obj: Any): String = {
obj.toString
Copy link
Member

Choose a reason for hiding this comment

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

Hmm .. shouldn't this be defined under the instance instead of the type itself?

Copy link
Member

Choose a reason for hiding this comment

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

Okie read the PR description. I am fine with this

@dongjoon-hyun
Copy link
Member

Merged to master for Apache Spark 4.1.0.
Thank you, @yaooqinn and @HyukjinKwon .

@yaooqinn yaooqinn deleted the SPARK-52583 branch June 27, 2025 02:08
@yaooqinn
Copy link
Member Author

Thank you @dongjoon-hyun @HyukjinKwon

@cloud-fan
Copy link
Contributor

late LGTM

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.

4 participants