apache / apache/datafusion

Create physical scalar expression in `functions` modules from string (name)

Aperta
#9,892 16 commenti 1 reazione 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Rust
Stelle
9.3k
Fork
2.4k
Merge medio
3g 11h
PR unite (30g)
360

Descrizione

### Is your feature request related to a problem or challenge?

#### Create physical scalar expression in functions modules from string
Currently more and more built-in scalar functions are moved to `functions` modules, e.g. https://github.com/apache/arrow-datafusion/pull/9435. It avoids using a long enum of all built-in scalar functions which is hard to maintain. But for Comet, we rely the ability to create a physical scalar expression from string (e.g., `datepart`).

Previously it is easy and just calls `BuiltinScalarFunction::from_str` to get `BuiltinScalarFunction`. But now I don't see such convenient function to do that.

`FunctionRegistry` provides `udf` which can return a reference to `ScalarUDF`. But it requires these UDFs must be registered. As we don't know what UDFs will be used, we need to register all built-in UDFs in the registry. The flaw is, it will create `ScalarUDF`s for all built-in UDFs even they are not actually used in the queries.

I think we still need an approach that can simply create a physical scalar expression in `functions` modules from string. So we can create corresponding `ScalarUDF` on demand.

Another approach might be to avoid creating `ScalarUDF`s when registering built-in scalar functions.

#### Avoid creating `ScalarUDF`s before they are actually used when registering in `FunctionRegistry`

Actually, I am also wondering if it is necessary to create and register all these `ScalaUDF`s in DataFusion's `FunctionRegistry` before these scalar UDFs are actually used.

For example, Spark's `FunctionRegistry` registers expression builders instead of creating actual expressions when registering built-in expressions. A built-in expression is created only if it is actually used by a query.

### Describe the solution you'd like

_No response_

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia tracciando FunctionRegistry::udf e i moduli delle funzioni integrate, quindi confrontali con il precedente percorso BuiltinScalarFunction::from_str. Determina come un nome possa produrre su richiesta un’espressione scalare fisica o uno ScalarUDF senza registrare prima ogni funzione integrata. L’attività è completata quando l’obiettivo dell’issue relativo alla ricerca basata su stringhe e alla creazione lazy è risolto con una copertura adeguata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
backend
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.