[SPARK-59364][UDF] Build external UDF payload and Init messages - #58713
Draft
haiyangsun-db wants to merge 2 commits into
Draft
[SPARK-59364][UDF] Build external UDF payload and Init messages#58713haiyangsun-db wants to merge 2 commits into
haiyangsun-db wants to merge 2 commits into
Conversation
haiyangsun-db
marked this pull request as draft
September 10, 2026 20:20
Contributor
|
@haiyangsun-db please let me know once this PR is ready for review |
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?
This PR adds the session initialization metadata needed by the language-neutral external UDF
framework:
authorized environment variables, and required resource directories.
Initmessages fromExternalUserDefinedFunction, including logical inputmetadata, named arguments, invocation identity, payload format, and evaluation type.
PythonUDFexpressions.specifications.
The existing Python UDF execution path is not switched to unified execution by this PR.
Why are the changes needed?
The external UDF framework can describe and launch workers, but it does not yet have a generic
contract for the per-session engine context or invocation metadata a worker needs. Without that
contract, physical execution would need language-specific knowledge, and Catalyst child rewrites
could leave serialized input metadata stale.
These changes keep worker requirements declarative, forward only engine-authorized context, and
rebuild logical input metadata from the current expression children.
Does this PR introduce any user-facing change?
No. This extends unreleased external UDF infrastructure and does not change the execution path of
existing Python UDFs.
How was this patch tested?
Added
PythonExternalUserDefinedFunctionSuitecoverage for context selection, required andoptional dynamic configuration, conflicting targets, named resource directories, rewritten and
named input metadata, Python worker configuration declarations, unsupported evaluation types, and
versioned payload decoding.
The protocol module and SQL tests were compiled, then the focused suites were run with:
build/sbt -java-home /usr/lib/jvm/java-17-openjdk-amd64 \ udf-worker-proto/compile \ sql/Test/compile \ 'sql/testOnly org.apache.spark.sql.execution.externalUDF.PythonExternalUserDefinedFunctionSuite org.apache.spark.sql.execution.externalUDF.PythonUDFWorkerSpecificationSuite org.apache.spark.sql.execution.externalUDF.PlanExternalUDFsSuite'All 39 executed tests passed. One environment-gated Python worker test was canceled because
PySpark was unavailable in the local Python environment.
Was this patch authored or co-authored using generative AI tooling?
Yes