COALESCE does not work with empty strings as documentation states it would
- Dominant language
- Java
- Stars
- 14.1k
- Forks
- 3.8k
- Avg merge
- 2d 58m
- Merged PRs (30d)
- 233
Description
### Affected Version
0.16.0 and 0.17.0
### Description
COALESCE does NOT work with empty strings
```
SELECT
COALESCE('something', 'fallback') AS tst1,
COALESCE(null, 'fallback') AS tst2,
COALESCE('', 'fallback') AS tst3
```
this yields
"something", "fallback", ""
According to the documentation, the third projection should also yield the output "fallback"
> COALESCE(value1, value2, ...) | Returns the first value that is neither NULL nor empty string.
I would petition to keep the documentation as is and modify the function behaviour to be conformant to the documentation as it would be quite useful if COALESCE could also deal with empty strings.
Contributor guide
Research direction
Reproduce the reported COALESCE query against the affected Druid versions, then locate the COALESCE implementation and its documentation entry. Confirm the intended handling of empty strings and add or update coverage so the query returns "fallback" for the empty-string case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100