Expose Python UDF inlining as a public, reusable extension codec

未关闭
#1,704 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
48/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
python, rust

调研方向

从 crates/core/src/codec.rs 以及 PythonLogicalCodec、PythonPhysicalCodec 和 SessionContext.with_python_udf_inlining 入口开始。在确定应如何将公共 codec 安装到链中之前,先阅读依赖 #1703 和 #1678 中的 codec 组合变更。完成的标准是,外部 Rust 消费者可以添加公共 codec,并保留现有的 Python UDF wire format,而无需重新实现其 payload framing。

由索引模型根据 Issue 内容生成。

描述

enhancement rust

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

datafusion-python can serialize a Python scalar UDF inline, by cloudpickling the function together with its schemas and volatility, so a plan referencing a Python UDF round-trips into a process that does not have that function registered. This is what SessionContext.with_python_udf_inlining turns on.

That capability is not reachable from outside the crate. PythonFunctionScalarUDF is pub(crate), and encode_python_scalar_udf / decode_python_scalar_udf in crates/core/src/codec.rs are private; only the try_encode_python_scalar_udf / try_decode_python_scalar_udf wrappers are pub(crate), and they are called from the two codecs this crate installs on every session. A Rust project that already has its own physical extension codec, and wants Python UDFs to travel through it, has to reimplement the cloudpickle framing to stay wire-compatible. Requested in https://github.com/apache/datafusion-python/pull/1678#pullrequestreview-5100366976.

Describe the solution you'd like

Extract the inlining behavior into its own LogicalExtensionCodec / PhysicalExtensionCodec implementation and make that type public, rather than exporting two free functions and a struct. Since #1678 made codecs compose, with_python_udf_inlining can then install that codec into the chain instead of being a flag consulted inside PythonLogicalCodec and PythonPhysicalCodec, and an outside consumer can put the same type in its own chain and get the same wire format for free. Suggested independently in https://github.com/apache/datafusion-python/pull/1678#discussion_r3918287124.

A public codec is a better thing to commit to than the current internals. It hides the payload layout, which is versioned and should stay free to change, and it exposes the behavior at the granularity DataFusion already understands.

Describe alternatives you've considered

Marking the existing functions and PythonFunctionScalarUDF pub as they stand. Smaller, but it publishes the payload layout as API, and it does not compose with anything — a caller still has to decide where in its own codec to call them.

Additional context

Depends on #1703, gating pyo3/extension-module, since the crate cannot currently be linked as a plain Rust dependency. Follow-up from #1678.

主要语言
Python
星标
605
派生
176
平均合并
1 天 23 小时
30 天内合并 PR
8

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion-python 的其他 Issue

查看 apache/datafusion-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。