apache / apache/datafusion

coalesce(Int, Utf8) coerces to Int

Open
#23,045 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Describe the bug

Type coercion of `COALESCE` returns Int even when there are string arguments. This is not always correct, as '' is a valid string but cannot be converted to int.

### To Reproduce

```sql
SELECT coalesce(1,'')
```

should be typed as a string, not int

### Expected behavior

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by running the reported SQL reproduction, SELECT coalesce(1,''), and inspect how COALESCE determines its result type. Compare the inferred type with the expected string type and add or update coverage for this case; done means string arguments are not incorrectly coerced to Int.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.