[SPARK-58275][SQL][PYTHON] Add normalize Unicode normalization SQL …#57450
Open
SreeramaYeshwanthGowd wants to merge 1 commit into
Open
[SPARK-58275][SQL][PYTHON] Add normalize Unicode normalization SQL …#57450SreeramaYeshwanthGowd wants to merge 1 commit into
SreeramaYeshwanthGowd wants to merge 1 commit into
Conversation
SreeramaYeshwanthGowd
force-pushed
the
add-normalize-function
branch
from
July 23, 2026 03:04
6697570 to
285b6bf
Compare
normalize Unicode normalization SQL …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add a built in
normalize(str[, form])scalar function that performs Unicode normalization using the JVM'sjava.text.Normalizer.API surface added:
normalize(str)andnormalize(str, form)functions.normalize(col)andfunctions.normalize(col, form)pyspark.sql.functions.normalize(str, form=None)Key design choices:
date_trunc). This keeps the change small and idiomatic and avoids adding new grammar. An invalid form raises a clearINVALID_PARAMETER_VALUE.NORMALIZE_FORMerror.RuntimeReplaceableexpression backed by aStaticInvokeintoExpressionImplUtils, so there is no hand written codegen, following the recenthmacfunction.Why are the changes needed?
Unicode normalization is a common need in text processing and data cleaning, for example to compare strings that look identical but differ in code point composition. Spark has no built in way to do this, so users fall back to a UDF, which cannot be optimized by Catalyst. This function is part of the SQL standard and is already available in PostgreSQL, Trino, and Google BigQuery, so it also improves parity with the engines that Spark users migrate from.
Does this PR introduce any user-facing change?
Yes. It adds a new built in SQL function
normalizeand the corresponding Scala and PySpark DataFrame API entries. No existing behavior changes.Example:
How was this patch tested?
Added unit tests in
ExpressionImplUtilsSuiteandStringExpressionsSuitecovering all four forms (NFC, NFD, NFKC, NFKD), a case insensitive form name, null propagation, empty input, a supplementary (surrogate pair) character, and the invalid form error. Added a DataFrame API test inStringFunctionsSuite, a PySpark test intest_functions.py, and SQL golden tests instring-functions.sqlwith regenerated results. Also regeneratedsql-expression-schema.md.Was this patch authored or co-authored using generative AI tooling? No