Skip to content

[SPARK-54878][SQL] Support sort_keys option inside to_json#54810

Open
judycheung-piaopiao wants to merge 3 commits intoapache:masterfrom
judycheung-piaopiao:SPARK-54878
Open

[SPARK-54878][SQL] Support sort_keys option inside to_json#54810
judycheung-piaopiao wants to merge 3 commits intoapache:masterfrom
judycheung-piaopiao:SPARK-54878

Conversation

@judycheung-piaopiao
Copy link

What changes were proposed in this pull request?

Add a new JSON write option sortKeys. When enabled, map keys are shown in lexicographical order.

Why are the changes needed?

Currently to_json() doesn't support the sort options, which makes comparing JSON strings from MapType inconvenient.

Does this PR introduce any user-facing change?

Yes. if setting as true, JSON object keys are sorted alphabetically. If "false", it works in default.

How was this patch tested?

Add unit tests in JacksonGeneratorSuite, JsonFunctionsSuite, PySpark tests in test_functions.py.

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

Cooperate with GPT-5.1

@sarutak
Copy link
Member

sarutak commented Mar 15, 2026

Dupulicate of #54717 ?

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.

2 participants