zhengruifeng opened a new pull request, #58265:
URL: https://github.com/apache/spark/pull/58265

   ### What changes were proposed in this pull request?
   
   This draft PR prototypes a PySpark API for registering an inline Java source 
UDF:
   `spark.udf.registerJvmFunctionFromSource(...)`.
   
   The prototype:
   
   - Adds the PySpark classic API and exposes it in the UDF API docs.
   - Compiles complete Java source units with the existing JDK code compiler 
plumbing.
   - Packages all generated classes into a deterministic session JAR and adds 
it through the session
     artifact manager.
   - Delegates registration and return type inference to the existing Java UDF 
registration path.
   - Adds a Spark Connect API stub that reports the feature as not implemented.
   - Adds tests for compiling full Java source units and registering/executing 
an inline Java UDF.
   - Adds a draft design document for inline JVM UDF source registration.
   
   ### Why are the changes needed?
   
   `spark.udf.registerJavaFunction` requires users to compile JVM UDF code into 
a JAR and make that
   JAR visible to Spark before registration. That is awkward for interactive 
PySpark workflows,
   especially when the UDF body is small and naturally lives near the Python 
code using it.
   
   This prototype explores a path where PySpark can submit Java source to the 
session JVM, compile it
   once, distribute the generated classes through Spark's existing artifact 
mechanism, and execute it
   through the existing JVM UDF path.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. This draft adds a new PySpark classic API:
   `UDFRegistration.registerJvmFunctionFromSource`.
   
   The current prototype supports Java source only. Spark Connect exposes the 
method but raises a
   not-implemented error.
   
   ### How was this patch tested?
   
   Tests were added in:
   
   - `python/pyspark/sql/tests/test_udf.py`
   - 
`sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeCompilerSuite.scala`
   
   Not run locally yet.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Codex
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to