apache / apache/datafusion-python

Expose SessionContext.register_variable / deregister_variable for SQL @var support

Aberta
#1,571 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Python
Estrelas
604
Forks
174
Merge médio
2d 22h
PRs com merge (30d)
5

Descrição

## Background

DataFusion's `SessionContext` exposes `register_variable(var_type, provider)` and `deregister_variable(var_type)` for plugging in a `VarProvider` that resolves SQL ``@var`` / ``@@var`` references at execution time. These were surfaced during a v54 upstream coverage audit but are not exposed in the Python bindings.

## Upstream signature

```rust
pub fn register_variable(&self, var_type: VarType, provider: Arc)
pub fn deregister_variable(&self, var_type: VarType) -> Option>
```

`VarProvider` is a small trait with `get_value(&self, name: Vec) -> Result` and `get_type(&self, name: &[String]) -> Option`.

## User value

Enables SQL like ``SELECT * FROM sales WHERE region = @current_region AND user_id = @user_id`` where the provider supplies per-query values. Useful for multi-tenant SaaS embedders, BI / notebook tools that want session-scoped parameters without f-string interpolation (no SQL injection risk), and tools porting MySQL / Postgres SQL that uses session variables.

## Why deferred

Effort estimate is medium (~250-400 LOC): needs a `PyVarProvider` Rust wrapper that calls back into a user-supplied Python object across the GIL boundary, plus the register / deregister bindings on `PySessionContext`, plus a Python-facing ABC. No open user requests at the time of audit, so the work is currently speculative. Filed for tracking; revisit when a concrete user need surfaces or to complete the upstream surface area.

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

A issue menciona PySessionContext, um wrapper Rust de PyVarProvider e uma ABC voltada para Python, mas não fornece arquivos nem testes. Comece rastreando os bindings existentes de PySessionContext e as assinaturas de register_variable e deregister_variable de SessionContext no upstream. A tarefa estará concluída quando os chamadores Python puderem fornecer um VarProvider, registrá-lo e removê-lo do registro, além de receber callbacks com segurança através da fronteira do GIL.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python, rust
Domínio
api, backend
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
38/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.