Kaicheng Zhou created SPARK-61655:
-------------------------------------

             Summary: Let a Rust UDF read the session's Python worker 
environment
                 Key: SPARK-61655
                 URL: https://issues.apache.org/jira/browse/SPARK-61655
             Project: Spark
          Issue Type: Improvement
          Components: Connect
    Affects Versions: connect-rust-4.3.0
            Reporter: Kaicheng Zhou


A session can set environment variables for its Python UDF workers with 
spark.pythonWorkerEnv.<NAME> (SPARK-58752, SPARK-59233, Spark 4.4.0). Python 
UDFs sent by the Rust client already receive them. A Rust UDF does not: it runs 
as a wasm32-unknown-unknown WebAssembly module that the runner instantiates 
without imports, so std::env::var always fails inside it.

Add spark_connect_build::embed_wasm_udf_for(src, WasmTarget::Wasip1) to build a 
UDF for wasm32-wasip1. When a module imports WASI, the runner gives it a 
snapshot of the worker's environment, without the names Spark reserves for its 
workers and without entries that aren't valid UTF-8. The module gets no files 
or arguments, and its standard output and error are discarded. Modules built 
for wasm32-unknown-unknown behave as before.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

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

Reply via email to