apache / apache/datafusion

Improve consistency and documentation on error handling in in UDFs

Aperta
#11,618 12 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Rust
Stelle
9.3k
Fork
2.4k
Merge medio
3g 11h
PR unite (30g)
362

Descrizione

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

When writing a new UDF, a developer needs to decide how to perform error management in functions that return `Result`, such as `return_type` and `invoke`. Looking at the existing codebase it is not obvious what are the error management best practices

# Errors in return type
- Regexp like uses an `plan_err` data types of args do not match the expected types https://github.com/apache/datafusion/blob/77311a5896272c7ed252d8cd53d48ec6ea7c0ccf/datafusion/functions/src/regex/regexplike.rs#L74 . Is this check redundant?

- Except expects two arguments but doesn't check the length, just the type https://github.com/apache/datafusion/blob/77311a5896272c7ed252d8cd53d48ec6ea7c0ccf/datafusion/functions-array/src/except.rs#L55.

# Errors in invoke

In the resize function, there is a check on argument lengths in invoke which is not present in the `return_type` function
https://github.com/apache/datafusion/blob/77311a5896272c7ed252d8cd53d48ec6ea7c0ccf/datafusion/functions-array/src/resize.rs#L27

The same function also returns `exec_err`, and `internal_datafusion_err`

### Describe the solution you'd like

As a developers of custom UDF I would like to know:
- what errors I need to check for and what are already checked by the planner (number of arguments?)
- what type of errors need to be raised in which conditions

### 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 confrontando return_type e invoke in datafusion/functions/src/regex/regexplike.rs e in datafusion/functions-array/src/except.rs e resize.rs, concentrandoti sui controlli degli argomenti e sulle varianti di errore riportate. Esamina come la validazione del planner si rapporta a queste funzioni; il lavoro è completato quando vengono documentati i controlli e i tipi di errore previsti e qualsiasi modifica di coerenza è coperta da test.

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

Valutazione

Stack tecnologico
rust
Ambito
documentation
Tipo di issue
Documentazione
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.