[SPARK-31945][SQL][PYSPARK] Enable cache for the same Python function. #28774
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 make
PythonFunction
holdsSeq[Byte]
instead ofArray[Byte]
to be able to compare if the byte array has the same values for the cache manager.Why are the changes needed?
Currently the cache manager doesn't use the cache for
udf
if theudf
is created again even if the functions is the same.This is because
PythonFunction
holdsArray[Byte]
, andequals
method of array equals only when the both array is the same instance.Does this PR introduce any user-facing change?
Yes, if the user reuse the Python function for the UDF, the cache manager will detect the same function and use the cache for it.
How was this patch tested?
I added a test case and manually.