UDF: consider returning an enum for `return_type`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- rust
- Ambito
- backend-api-design, databases
Direzione di ricerca
Start by reading the UDF trait methods in datafusion/expr/src/udf.rs, especially return_type() and return_field_from_args(), then compare the implementations in datafusion/functions/src/datetime/now.rs. Evaluate whether a unified UdfReturn API and enhanced ReturnFieldArgs can avoid dummy methods without an unacceptable migration burden; done means a reviewed design direction with its compatibility implications documented.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is your feature request related to a problem or challenge?
UDFs need to implement return_type():
But they can also implement return_field_from_args():
Which supersedes return_type(), but since return_type() still needs to be implemented so usually its made to return an internal error in that case:
This is kind of ugly since:
- Users have to read docs to implement it right (little help from compiler)
- Users might still implement
return_type()with an actual implementation even if they implementreturn_field_from_args(), soreturn_type()becomes dead code - Users might accidentally use
return_type()in their code for whatever reason, instead of correctly usingreturn_field_from_args()
Describe the solution you'd like
Consider having return type be determined like this:
enum UdfReturn {
ReturnType(DataType),
ReturnField(FieldRef),
}
fn returns(&self, args: ReturnFieldArgs) -> Result<UdfReturn> {
...
}
- And would need to enhance
ReturnFieldArgsto provide just input data types, for ergonomics
This allows us to unify the methods, where simpler UDFs can return the ReturnType variant if they dont care about nullability, field name, metadata, etc.
Describe alternatives you've considered
Don't do this. This is likely to be too breaking of a change, and its hard to migrate towards this path since Rust doesnt allow deprecating trait method implementations (as in it wont show a lint warning). But this was just an idea I had floating in my head and thought it worth recording, and seeing what others thoughts are.
Additional context
In general, I'm just not fond of seeing the approach of having to leave a dummy implementation for trait methods that wont be called. Another example is for UDFs that are meant to always be simplified, so they dont provide an invoke implementation:
It would be nice if we were able to structure the code in a way to avoid this code pattern, but perhaps the ship has sailed.
- Lingua principale
- Rust
- Stelle
- 9.3k
- Fork
- 2.4k
- Merge medio
- 3g 8h
- PR unite (30g)
- 354
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/datafusion
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apache/datafusion#25266 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
apache/datafusion#25213 · 1 commento ·
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
apache/datafusion#25168 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
apache/datafusion#24998 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
apache/datafusion#24913 ·
Tutte le issue di apache/datafusion
Issue simili
-
has_tail_capacity wraps and get_writable_raw_unchecked commits raw_len before the bounds check Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
stratum-mining/stratum#2404 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
Axis areas are always keyboard-focusable (Sense::drag), even with allow_axis_zoom_drag(false) Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
bug team:backend track:services-maintenance
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cowprotocol/services#4950 ·