[SPARK-35247][SQL] Add mask built-in function as a data masking function
#32372
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?
This PR proposes to add a new built-in function
maska data masking function which Hive already supports.Actually, Hive supports 6 data masking functions.
I'll implement all of them but I'd like to introduce the most basic one in this PR.
maskin this PR is implemented to be compatible with the Hive's implementation.In Hive, there is a [document}(https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DataMaskingFunctions) for data masking functions but it seems outdated so I referred to the Hive's source code.
https://github.com/apache/hive/blob/rel/release-2.3.8/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFMask.java
Actually, Hive's data masking functions can be applied to not only characters but also numeric types and date type.
In this PR,
masksupports onlyStringTypebut I'll extends it for other types. So, this new function is categolized as a new groupdata_masking_funcsrather thanstring_funcs.Why are the changes needed?
For data masking,
maskis more useful thanreplaceortranslate.Does this PR introduce any user-facing change?
Yes. Users can use the new built-in function.
How was this patch tested?
New tests.