apache / apache/datafusion-python
Expose SessionContext.register_higher_order_function / deregister_higher_order_function (v54)
- Linguagem predominante
- Python
- Estrelas
- 604
- Forks
- 174
- Merge médio
- 1d 7h
- PRs com merge (30d)
- 4
Descrição
## Background
DataFusion 54 introduced first-class higher-order functions (HOFs) that take lambdas plus collection arguments and rewrite to a scalar `Expr` at planning time. PR #1561 exposed Python lambda syntax and the built-in HOFs (``array_transform``, ``array_filter``, ``array_any_match``, etc.) but did not expose the registration API for custom HOFs.
## Upstream signature
```rust
pub fn register_higher_order_function(&self, func: Arc)
pub fn deregister_higher_order_function(&self, name: &str) -> Option>
```
`HigherOrderFunctionImpl` trait requires `name()`, `args_count()` (min, max), and `invoke(&self, args: &[Expr]) -> Result`.
## User value
Lets library authors add lambda-aware operators that are not in DataFusion's built-in set. Examples: ``array_window(arr, size, x -> ...)``, ``array_partition_by(arr, x -> key(x))``, ``array_zip_with(a, b, (x, y) -> x * y)``, or domain-specific operators on JSON / graph / geo arrays. The HOF runs at logical-plan time, rewriting lambda + args into a standard Expr tree the planner optimizes -- not equivalent to a ScalarUDF.
## Why deferred
Effort estimate is medium-large (~350-550 LOC) and the authoring cost is high for end users: the ``invoke`` callback must return a DataFusion ``Expr`` tree from Python, which requires familiarity with the Expr grammar. Most array-lambda needs are already covered by the built-in HOFs PR #1561 ships. No open user requests at the time of audit. Filed for tracking to complete the v54 HOF surface symmetrically once a concrete use case or extension-library ecosystem emerges.
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
Comece lendo o PR #1561 e as assinaturas de registro upstream de SessionContext para HigherOrderFunctionImpl e Expr. Defina a API voltada para Python para registrar e desregistrar funções higher-order personalizadas, incluindo como invoke retorna um Expr; considera-se concluído quando a superfície de registro da v54 estiver exposta e utilizável pelos autores de bibliotecas.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python, rust
- Domínio
- api
- Tipo de issue
- Funcionalidade
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Status de atividade
- Pouca atividade
- Clareza
- Precisa de esclarecimento
- Facilidade para iniciantes
- 30/100