apache / apache/datafusion

Support `UNNEST` as table function (UDTF)

Aperta
#14,801 2 commenti 2 reazioni 1 assegnatario Rivendicata da @jonahgao 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?

`UNNEST` is implemented in two ways, `SELECT UNNEST(...)` is handled with other functions https://github.com/apache/datafusion/blob/84232d806070f4b177e35148255c501a5f6e740b/datafusion/sql/src/expr/function.rs#L246-L255

And `SELECT ... FROM UNNEST(...)` is provided as `TableFactory` https://github.com/apache/datafusion/blob/84232d806070f4b177e35148255c501a5f6e740b/datafusion/sql/src/relation/mod.rs#L117-L123

But those two ways are both non-generic, cases like substrait can't handle it properly, as the decoder will try to look for table function:

```rs
async fn roundtrip_unnest() -> Result<()> {
roundtrip("SELECT * FROM unnest([1, 2, 3])").await
}
```

### Describe the solution you'd like

Implement `UNNEST` as a table function, making it more general and reduce the complexity (and branches) of implementation

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.