Decode Python UDFs opaquely so a scheduler needs no Python interpreter
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
研究方向
先閱讀 crates/core/src/codec.rs 以及 #1678 中的 extension codec 工作,以了解 DFPYUDF wire format 與 codec 組合方式。圍繞現有 payload 設計 scheduler 端的 ScalarUDFImpl 和 codec,在重新編碼時保留 cloudpickle 位元組,同時公開可復原的 metadata,並讓 invoke 回傳錯誤。檢查 #1703 中的相依性脈絡。
由索引模型根據 Issue 內容生成。
描述
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
In a distributed setup the scheduler plans a query and hands stages to executors; only the executors ever call a Python UDF. Decoding an inlined Python UDF unpickles the function, which requires a Python interpreter and every module the function closes over to be importable. Doing that on the scheduler costs work nobody needs and forces the scheduler image to carry Python and the full dependency set of user code it will never run. Raised in https://github.com/apache/datafusion-python/pull/1678#pullrequestreview-5100366976.
Describe the solution you'd like
An opaque decode path: a ScalarUDFImpl that holds the still-pickled blob rather than a live Python object, and a codec that produces it. A scheduler installs that codec, decodes a plan into something it can inspect, route, and re-encode, and never touches cloudpickle. The executor installs the ordinary codec and unpickles as it does now.
The wire format already allows this. An inlined UDF payload is DFPYUDF followed by a version byte and the cloudpickle blob (crates/core/src/codec.rs), so an opaque holder can carry those bytes verbatim and no format change is needed.
The part that needs design is re-encoding. A scheduler that forwards a stage has to emit the blob byte-identically, so the executor sees exactly what the client wrote. That also raises what such a UDF should report for the things DataFusion asks of a ScalarUDFImpl during planning — name, signature, and return type are all recoverable from the payload without unpickling, since they are stored alongside the function, but invoke has to be an error rather than a surprise.
Describe alternatives you've considered
Encoding Python UDFs by name only and registering them on every node. Already supported and appropriate when the function is available everywhere; it does not cover the case inlining exists for, which is a function the receiving process does not have.
Having the scheduler unpickle and immediately drop the object. Keeps the code simple, and still requires Python plus all user dependencies on the scheduler, which is the actual cost being avoided.
Additional context
Follow-up from #1678, which made extension codecs compose so a setup like this can install a scheduler-side codec alongside others. Likely also depends on #1703, gating pyo3/extension-module, if the consumer is a Rust crate rather than a Python process.
- 主要語言
- Python
- 星號
- 606
- 分支
- 176
- 平均合併
- 1 天 7 小時
- 30 天內合併 PR
- 14
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/datafusion-python 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
apache/datafusion-python#1765 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
apache/datafusion-python#1760 ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 70/100
apache/datafusion-python#1757 ·
維護者通常 1 天內回覆
-
documentation
難度 2/5 1-3 小時 新手友好度 72/100
apache/datafusion-python#1726 ·
維護者通常 1 天內回覆
-
難度 2/5 半天 新手友好度 88/100
apache/datafusion-python#1691 ·
維護者通常 1 天內回覆
查看 apache/datafusion-python 的全部 Issue
相似的 Issue
-
upstream update
難度 2/5 1-3 小時 新手友好度 75/100
conan-io/conan-center-index#31098 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
john-kurkowski/tldextract#382 ·
-
comp/tools duplicate P2 sweeper:risk-compatibility tool/mcp type/bug
難度 1/5 1 小時以內 新手友好度 88/100
NousResearch/hermes-agent#132042 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
deepset-ai/haystack#13092 ·
維護者通常 1 天內回覆
-
難度 1/5 1-3 小時 新手友好度 85/100
feder-cr/invisible_playwright_mcp#1408 ·
維護者通常 1 天內回覆