apache / apache/datafusion

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

Open
#24,136 1 comment 0 reactions 1 assignee Claimed by @blinding-pixels View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.