apache / apache/datafusion

Coercible signature: how to specify some inputs should have exact same type?

Abierto
#24,136 1 comentario 0 reacciones 1 asignado Reclamado por @blinding-pixels Ver en GitHub
enhancement
Lenguaje dominante
Rust
Estrellas
9.3k
Forks
2.4k
Merge medio
3 d 11 h
PR fusionados (30 d)
360

Descripción

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

Looking at `btrim` for example:

https://github.com/apache/datafusion/blob/f27e50c13647efa5292d5ef5b1e4ed6af3015962/datafusion/functions/src/string/btrim.rs#L82-L93

It specifies it accepts 2 string input types. However the planner doesn't coerce them to a common type, leaving it up to the UDF to handle casting to a common type for simplicity (otherwise get explosion of string types to handle):

https://github.com/apache/datafusion/blob/f27e50c13647efa5292d5ef5b1e4ed6af3015962/datafusion/functions/src/string/btrim.rs#L32-L43

### Describe the solution you'd like

Some way in the coercible signature API to specify when inputs should have same type. We previously could do this via:

```rust
TypeSignature::Uniform(2, vec![Utf8, Utf8View, LargeUtf8])
TypeSignature::Exact(vec![Utf8, Utf8]) // and other variants
TypeSignature::String(2)
```

So if we want to still try move toward coercible API, it would be good to support this somehow otherwise its very much less ergonomic for UDFs to handle this logic themselves.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.